【问题标题】:Optimizing package randomForest speed using parallel processing使用并行处理优化包 randomForest 速度
【发布时间】:2019-09-07 03:48:05
【问题描述】:

我怎样才能获得以下代码(替代代码也很好),以提高使用多核并行工作的回归方程的 randomForest 分析速度?

#Parallelized Random Forest Model
RFcores <- detectCores()/3 + 4
RFcores
RFtrees <- 1000/RFcores
RFtrees
cl <- makeCluster(RFcores)
registerDoParallel(cl)
timer <- proc.time()
form <- as.formula(paste(a, "~", b))
fit <- foreach(ntree = rep(RFtrees, RFcores), .combine = gtable_combine, .packages = 'randomForest') %dopar% 
   { 
                randomForest(form, data = maindf, mtry = 4, 
                             keep.forest = FALSE, nodesize = 10000, do.trace = TRUE, maxnodes = 5, 
                            improve = 0.01, doBest = TRUE, importance = TRUE, ntree = ntree)}
proc.time() - timer
stopCluster(cl)
}

我在foreach 函数中不断收到以下与.combine argument 相关的错误。

error calling combine function:
<simpleError in align_2(x, y, along = along, join = join): Both gtables must have names along dimension to be aligned>

我期待对此问题的任何想法。

【问题讨论】:

    标签: r parallel-processing rstudio random-forest


    【解决方案1】:

    看看Parallel Statistical Computing with R: An Illustration on Two Architectures,它提供了两种并行化随机森林计算的方法:mclapplypbdMPI

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-21
      • 2016-03-14
      • 2023-03-15
      • 1970-01-01
      • 2020-09-02
      • 1970-01-01
      • 2011-08-01
      • 2016-07-29
      相关资源
      最近更新 更多