直接上代码

#RF code1
library(randomForest) library(readxl) data<- read_excel('***.xlsx',,sheet=1) #
Random sampling samplesize = 0.7 * nrow(data) # set.seed(80) index = sample(
seq_len ( nrow ( data ) ), size = samplesize ) # # Create training and test set
datatrain = data[ index, ] datatest = data[ -index, ]
#rf<-randomForest(ER~Tair+Tsoil+RH+VPD,data=datatrain ,mtry=4,ntree=1000)
rf<-randomForest(ER~.,data=datatrain ,mtry=4,ntree=1000) #predict prediction <-
predict(rf, datatest ) #calculate R2 and RMSE
#RF code2

待续...关于如何选择mtry和ntree

 

 

技术
©2019-2020 Toolsou All rights reserved,
Java开发2020年最新常见面试题整理【Spring源码分析】42-@Conditional详解element-ui踩坑记录神仙面试宝典你有了吗?半月看完25大专题,居然斩获阿里P8offer使用css样式设计一个简单的html登陆界面XCTF攻防世界web新手练习_ 9_command_executionJS中的解构赋值的详解与具体用途Python Web 框架elementui 穿梭框 el-transfer 展示列表内容文字过长ConcurrentHashMap实现原理及源码解析