【问题标题】:Parallel processing in caret does not work on R 2.13.0插入符号中的并行处理不适用于 R 2.13.0
【发布时间】:2012-06-16 01:01:07
【问题描述】:

我正在使用 R 包 caret 并且并行处理不起作用。如果我尝试从 train 函数运行示例:

library(mlbench)
data(BostonHousing)

library(doMC)
registerDoMC(2)

## NOTE: don't run models form RWeka when using
### multicore. The session will crash.

## The code for train() does not change:
set.seed(1)
usingMC <-  train(medv ~ .,
                  data = BostonHousing, 
                  "glmboost")

我收到以下错误:

Error in names(resamples) <- gsub("^\\.", "", names(resamples)) : 
  attempt to set an attribute on NULL

我使用的是 2011 年初型号的 MacBook Pro,配备 2.3GHz Intel Core i5 和 Mac OS X 10.6.8。

R 会话信息:

R 版本 2.13.0 (2011-04-13) 平台: x86_64-apple-darwin9.8.0/x86_64(64位)

附加的基础包:[1] stats graphics grDevices utils
数据集方法库

其他附加包:[1] caret_5.13-20 cluster_1.14.2 reshape_0.8.4 plyr_1.7.1 lattice_0.19-33 mlbench_2.1-0
doMC_1.2.3 multicore_0.1-7 [9] foreach_1.3.2 codetools_0.2-8 iterators_1.0.5

通过命名空间加载(未附加):[1] compiler_2.13.0 grid_2.13.0 rpart_3.1-51 tools_2.13.0

我能做些什么来解决这个问题吗?

【问题讨论】:

  • 在将trainmethod = "gbm" 一起用于其他数据时,我随机收到相同的错误消息。我没有看到像svmLinear, svmPoly, svmRadial, svmRadialCost, rda 这样的方法的错误。

标签: r r-caret


【解决方案1】:
  1. 可能很难找到可以重现您的错误的人:使用

    > sessionInfo ()
    R version 2.15.0 (2012-03-30)
    Platform: x86_64-pc-linux-gnu (64-bit)
    

    [...剪辑...]

    other attached packages:
     [1] mboost_2.1-2    caret_5.15-023  cluster_1.14.2  reshape_0.8.4  
     [5] plyr_1.7.1      lattice_0.20-6  doMC_1.2.5      multicore_0.1-7
     [9] iterators_1.0.6 foreach_1.4.0   mlbench_2.1-0          
    
    loaded via a namespace (and not attached):
    [1] codetools_0.2-8  compiler_2.15.0  grid_2.15.0      Matrix_1.0-6    
    [5] splines_2.15.0   survival_2.36-14 tools_2.15.0    
    

    它有效。

  2. 这意味着您可能需要深入研究代码:traceback ()debug () 应该会有所帮助。

【讨论】:

    【解决方案2】:

    至少在 2.14.0 上,我无法重现该问题(见下文)。

    插入符号代码没有用于顺序和并行处理的不同版本,所以我不确定问题出在哪里。顺序版本有用吗?其他型号呢?您也可以尝试新的会话吗?

    此外,您可能希望直接向软件包维护者发送电子邮件(除非您发送了邮件但我错过了)以获得更好的结果。

    > library(caret)
    

    > library(mlbench)
    > data(BostonHousing)
    > 
    > library(doMC)
    

    > registerDoMC(2)
    > 
    > ## NOTE: don't run models form RWeka when using
    > ### multicore. The session will crash.
    > 
    > ## The code for train() does not change:
    > set.seed(1)
    > usingMC <-  train(medv ~ .,
    +                   data = BostonHousing, 
    +                   "glmboost")
    Warning message:
    In glmboost.matrix(x = c(0.00632, 0.02731, 0.02729, 0.03237, 0.06905,  :
      model with centered covariates does not contain intercept
    > usingMC
    506 samples
     13 predictors
    
    No pre-processing
    Resampling: Bootstrap (25 reps) 
    
    Summary of sample sizes: 506, 506, 506, 506, 506, 506, ... 
    
    Resampling results across tuning parameters:
    
      mstop  RMSE  Rsquared  RMSE SD  Rsquared SD
      50     5.44  0.663     0.484    0.0661     
      100    5.33  0.675     0.518    0.0669     
      150    5.27  0.681     0.526    0.0661     
    
    Tuning parameter 'prune' was held constant at a value
     of 'no'
    RMSE was used to select the optimal model using 
     the smallest value.
    The final values used for the model were mstop = 150
     and prune = no. 
    > sessionInfo()
    R version 2.14.0 (2011-10-31)
    Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
    
    locale:
    [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
    
    attached base packages:
    [1] stats     graphics  grDevices utils     datasets 
    [6] methods   base     
    
    other attached packages:
     [1] mboost_2.1-1    doMC_1.2.5      multicore_0.1-7
     [4] iterators_1.0.5 mlbench_2.1-0   caret_5.15-023 
     [7] foreach_1.4.0   cluster_1.14.1  reshape_0.8.4  
    [10] plyr_1.7.1      lattice_0.20-0 
    
    loaded via a namespace (and not attached):
    [1] codetools_0.2-8  compiler_2.14.0  grid_2.14.0     
    [4] Matrix_1.0-3     splines_2.14.0   survival_2.36-10
    [7] tools_2.14.0  
    

    【讨论】:

    • 这个bug很奇怪。今天我在 OpenStack 集群上运行插入符号时遇到了完全相同的问题。然而,我意识到当我注释掉 registerDoMC() 时,代码运行成功。
    猜你喜欢
    • 2017-11-30
    • 2015-06-27
    • 2011-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多