【问题标题】:Caret train method complains when trying to use H2o package: "Something is wrong; all the Accuracy metric values are missing"Caret train 方法在尝试使用 H2o 包时抱怨:“出了点问题;所有准确度指标值都丢失了”
【发布时间】:2020-11-30 05:09:18
【问题描述】:

当我想在此示例中使用插入符号中的 H2o 方法时收到错误消息:

library(caret)
library(h2o)

data(HELPrct)
ds = HELPrct
fitControl= trainControl(method="repeatedcv", number = 5)
ds$sub = as.factor(ds$substance)
h2oFit1 <- train(homeless ~ female + i1 + sub + sexrisk + mcs + pcs, 
               trControl=fitControl, 
               method = "gbm_h2o", 
               data=ds[complete.cases(ds),])

然后R告诉我:

Something is wrong; all the Accuracy metric values are missing:
   Accuracy       Kappa    
 Min.   : NA   Min.   : NA
 1st Qu.: NA   1st Qu.: NA
 Median : NA   Median : NA
 Mean   :NaN   Mean   :NaN 
 3rd Qu.: NA   3rd Qu.: NA
 Max.   : NA   Max.   : NA  
 NA's   :9     NA's   :9 
Error: Stopping
In addition: Warning message:
In nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo,  :
  There were missing values in resampled performance measures.

有谁知道我如何使插入符号与 h2o 一起工作?其他方法都没有问题。

【问题讨论】:

    标签: r r-caret h2o


    【解决方案1】:

    如果我运行您的代码并检查警告:

    warnings()
    Warning messages:
    1: model fit failed for Fold1.Rep1: max_depth=1, ntrees= 50, learn_rate=0.1, min_rows=10, col_sample_rate=1 Error in h2o.getConnection() : 
      No active connection to an H2O cluster. Did you run `h2o.init()` ?
    

    所以你需要h2o.init()(查看webpage了解更多详情):

    library(caret)
    library(h2o)
    
    h2o.init()
    ds = mosaicData::HELPrct
    
    fitControl= trainControl(method="repeatedcv", number = 5)
    ds$sub = as.factor(ds$substance)
    h2oFit1 <- train(homeless ~ female + i1 + sub + sexrisk + mcs + pcs, 
                   trControl=fitControl, 
                   method = "gbm_h2o", 
                   data=ds[complete.cases(ds),])
    
    h2oFit1
    Gradient Boosting Machines 
    
    117 samples
      6 predictor
      2 classes: 'homeless', 'housed' 
    
    No pre-processing
    Resampling: Cross-Validated (5 fold, repeated 1 times) 
    Summary of sample sizes: 93, 94, 93, 94, 94 
    Resampling results across tuning parameters:
    
      max_depth  ntrees  Accuracy   Kappa    
      1           50     0.5826087  0.0669072
      1          100     0.6253623  0.1895957
      1          150     0.6420290  0.2188447
      2           50     0.6159420  0.1708235
      2          100     0.6072464  0.1513658
      2          150     0.6329710  0.2035319
      3           50     0.6253623  0.1878658
      3          100     0.6159420  0.1701928
      3          150     0.6420290  0.1761487
    

    【讨论】:

      猜你喜欢
      • 2015-10-19
      • 1970-01-01
      • 2016-07-10
      • 2015-08-14
      • 2016-01-10
      • 2016-12-21
      • 1970-01-01
      • 2021-04-01
      • 2015-08-09
      相关资源
      最近更新 更多