【发布时间】: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