昨天我更新了我的R包,从那时起,然后并行执行列车函数失败。

似乎是从工人内部调用的一些功能。这些功能至少是令人乐常的和经验功能。

我在生产机器上遇到这个问题,并且能够在清洁的Windows 7 x64 VM上重现它。

我添加了下面的最小工作示例。亲爱的Stackoverflow的用户:任何帮助都赞赏!

# R 3.0.2 x64, RStudio Version 0.98.490, Windows 7 x64

data(iris)
library(caret) # 6.0-21
library(doParallel) # 1.0.6

model <- "rf"

# Fail
?probFunction
?flatTable

fitControl <- trainControl(
  method = "repeatedcv"
  , number = 5  ## 5-fold CV
  , repeats = 1   ## repeated one times
  , verboseIter =TRUE
)

#### Sequential Version ####

# Runs
train(Species ~ ., data = iris, method = model, trControl = fitControl)

#### Parallelized version ####

# Fails with 
# Error in e$fun(obj, substitute(ex), parent.frame(), e$data) : 
#  worker initialization failed: Error in eval(expr, envir, enclos): could not find function "flatTable"
cl <- makeCluster(3)
registerDoParallel(cl)

train(Species ~ ., data = iris, method = model, trControl = fitControl)

stopCluster(cl)

# Fails with 
# Error in { : task 1 failed - "could not find function "probFunction""
fitControl <- trainControl(
  method = "repeatedcv"
  , number = 5  ## 5-fold CV
  , repeats = 1   ## repeated one times
  , verboseIter =TRUE
  , classProbs = TRUE
)

cl <- makeCluster(3)
registerDoParallel(cl)

train(Species ~ ., data = iris, method = model, trControl = fitControl)

stopCluster(cl)

#### Again sequential version ####

# Fails with
# Error in summary.connection(connection) : invalid connection
train(Species ~ ., data = iris, method = model, trControl = fitControl)
.

r会话信息

R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252    LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=C                    LC_TIME=German_Germany.1252   

attached base packages:
[1] parallel  stats     graphics  grDevices utils     datasets  methods   base    

other attached packages:
[1] e1071_1.6-1        class_7.3-9        randomForest_4.6-7 doParallel_1.0.6   iterators_1.0.6  
[6] foreach_1.4.1      caret_6.0-21       ggplot2_0.9.3.1    lattice_0.20-23  

loaded via a namespace (and not attached):
[1] car_2.0-19         codetools_0.2-8    colorspace_1.2-4   compiler_3.0.2     dichromat_2.0-0  
 [6] digest_0.6.4       grid_3.0.2         gtable_0.1.2       labeling_0.2       MASS_7.3-29      
[11] munsell_0.4.2      nnet_7.3-7         plyr_1.8           proto_0.3-10       RColorBrewer_1.0-5
[16] reshape2_1.2.2     scales_0.2.3       stringr_0.6.2      tools_3.0.2      
.

有帮助吗?

解决方案

您所获得的错误是由Caret 6.0-21中的错误引起的,当使用Doparallel,Dosnow和Dompi时。它已在R-Forge版本6.0-22中修复,但尚未释放到CRAN。如果您不想等待释放的新版本,您可以:

  1. 降级到插座5.x
  2. 从R-Forge
  3. 安装Caret 6.0-22
  4. 安装和使用来自R-Forge的DOSNow 1.0.10而不是多法驱动
  5. 问题是由禁止使用:::运算符的CRAN策略的变化引起的,即使在引用来自同一包内的非导出函数时也是如此。


    更新

    印章6.0-22在2014-01-18释放到Cran。这应该使用带有DOSNow和类似的并行后端的插入符号来解决报告的问题。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top