并行randomForest,其中foreach没有在R中并行运行任何东西

时间:2016-08-25 08:19:40

标签: r windows parallel-processing random-forest parallel-foreach

我试图在笔记本电脑的4个核心上并行使用randomForest,使用foreach包获取一些数据x并使用代码响应y:

    rf <- foreach(ntree=rep(200, 3), .combine=combine, .packages='randomForest', verbose=TRUE) %dopar% {  
  randomForest(x, as.factor(y), ntree=ntree, mtry=6 , keep.forest=TRUE, seed=1, replace=TRUE)
         }

但是,即使群集设置如下,它也不起作用,所以安装了randomForest,但只有200棵树而不是600棵。

 library(randomForest)
 library(foreach)
 library(doParallel)

 no_cores <- detectCores()  # Number of cores
 cl<-makeCluster(no_cores) #4
 registerDoParallel(cl)

我想知道如何解决这个问题,或者我是否必须更改设置以允许R访问多个内核?我有一个Windows 10笔记本电脑,如果这有帮助。

感谢您的帮助!

0 个答案:

没有答案