【发布时间】:2016-03-14 16:29:07
【问题描述】:
我正在尝试使用 rfcv 函数进行多元随机森林特征选择。我设法让正常的 rf 命令(构建随机森林)模型使用以下方法进行并行处理:
library(randomForest)
library(doMC)
nCores <- detectCores();
registerDoMC(nCores) #number of cores on the machine
rf.model <- foreach(ntree=rep(round(510/nCores),nCores), .combine=combine, .multicombine=TRUE, .packages="randomForest") %dopar% {
rf <- randomForest(y = outcome, x = predictor, ntree=ntree, mtry=4, norm.votes=FALSE, importance=TRUE)
}
在使用这个之前,我想使用 rfcv 进行我的功能选择。我尝试使用以下方法按上述方式进行操作:
rf.model <- foreach(1:nCores, .packages="randomForest") %dopar% {
rf.rfcv <- rfcv(ytrain = outcome, xtrain = predictor, scale=4)
}
但是,这个函数的结果多次重复,所以我只得到 rf.rfcv 作为 4 个相同结果的列表。
任何帮助将不胜感激!谢谢!
【问题讨论】:
标签: r random-forest feature-selection