r语言 - 插入符号火车方法在尝试使用 H2o 包时抱怨:"Something is wrong; all the Accuracy metric values are missing"



当我想在这个例子中使用插入符号中的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.

有人知道我如何让caret与h2o一起工作吗?其他方法不会产生任何问题。

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

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()(查看网页了解更多详细信息(:

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

相关内容

最新更新