相关疑难解决方法(0)

R中随机森林的并行执行

我在R中并行运行随机森林

library(doMC)
registerDoMC()
x <- matrix(runif(500), 100)
y <- gl(2, 50)
Run Code Online (Sandbox Code Playgroud)

并行执行(耗时73秒)

rf <- foreach(ntree=rep(25000, 6), .combine=combine, .packages='randomForest') %dopar%
randomForest(x, y, ntree=ntree) 
Run Code Online (Sandbox Code Playgroud)

顺序执行(耗时82秒)

rf <- foreach(ntree=rep(25000, 6), .combine=combine) %do%
randomForest(x, y, ntree=ntree) 
Run Code Online (Sandbox Code Playgroud)

在并行执行中,树生成非常快,如3-7秒,但其余时间用于组合结果(组合选项).因此,它唯一值得运行并行执行的是树的数量真的很高.有什么方法可以调整"组合"选项,以避免在我不需要的每个节点上的任何计算,并使其更快

PS.以上只是数据的一个例子.实际上,对于大约100个观察,我有大约10万个特征.

parallel-processing r

28
推荐指数
3
解决办法
2万
查看次数

标签 统计

parallel-processing ×1

r ×1