R包partykit函数cforest如何与applyfun参数一起使用以在Windows上进行多核并行处理

问题描述 投票:0回答:1
R

cforest

 包中的 
partykit
 函数有一个参数 
applyfun
文档 指出可用于应用“带有参数 function(X, FUN, ... )”。据我了解,mclapply
 在 Windows 操作系统上不起作用,
parLapply
 是 Windows 上 
lapply
 的“直接”并行替代方案,根据 
parLapply(cl = NULL, X, fun, ...)
 文档,其形式为 
cforest

尝试一下的一些基本代码:

library(partykit) library(parallel) nCores <- detectCores() clust <- makeCluster(nCores) data(iris) rf_model = cforest(Species~., data=iris, applyfun=parLapply(clust))
给予

cforest(物种 ~ ., data = iris, applyfun = parLapply(clust)) 中的错误: 未使用的参数 (applyfun = parLapply(clust))

如何在 Windows 上的

parallel

 函数中正确使用 
cforest
 函数作为输入参数?

r windows parallel-processing random-forest partykit
1个回答
0
投票
nCores <- detectCores() clust <- makeCluster(nCores) parLapplyClust <- function(X, FUN, ...) { parLapply(clust, X, FUN, ...) } data(iris) rf_model <- cforest(Species~., data=iris, applyfun=parLapplyClust) stopCluster(clust)
    
© www.soinside.com 2019 - 2024. All rights reserved.