【问题标题】:cross validation predictions from H2O autoML modelH2O autoML 模型的交叉验证预测
【发布时间】:2019-10-04 12:35:01
【问题描述】:

根据 h2o 文档,我可以设置 keep_cross_validation_predictions = T 以从我的 automl 模型中获取交叉验证预测。

但我无法让它工作。

使用文档中的这个例子

library(h2o)

h2o.init()

# Import a sample binary outcome train/test set into H2O
train <- h2o.importFile("https://s3.amazonaws.com/erin-data/higgs/higgs_train_10k.csv")
test <- h2o.importFile("https://s3.amazonaws.com/erin-data/higgs/higgs_test_5k.csv")

# Identify predictors and response
y <- "response"
x <- setdiff(names(train), y)

# For binary classification, response should be a factor
train[,y] <- as.factor(train[,y])
test[,y] <- as.factor(test[,y])

# Run AutoML for 20 base models (limited to 1 hour max runtime by default)
aml <- h2o.automl(x = x, y = y,
                  training_frame = train,
                  max_models = 20,
                  keep_cross_validation_predictions = TRUE,
                  seed = 1)

运行模型后,我尝试了

h2o.cross_validation_predictions(aml)
h2o.cross_validation_predictions(aml@leader)

h2o.cross_validation_holdout_predictions(aml)
h2o.cross_validation_holdout_predictions(aml@leader)

但这些都不起作用。

edit我使用的是最新的稳定版 3.24.02

【问题讨论】:

  • 感谢您的提问@spore234。您能否说明您使用的是哪个版本的h2o

标签: r h2o automl


【解决方案1】:

@spore234 我猜你的领导者是一个 Stacked Ensemble 模型,这个模型不应该有任何交叉验证预测。

我们可能应该为这种情况提供一个有意义的警告。

让我也指出以下一行:

h2o.cross_validation_predictions(aml)

将抛出一个有意义的错误,因为用户应该传递一个 H2OModel 对象,但 amlH2OAutoML 类的一个实例。

【讨论】:

  • 我想我设法得到这样的 CV 预测:model_ids &lt;- as.data.frame(m@leaderboard$model_id)[,1]; se &lt;- h2o.getModel(grep(model_ids[1], model_ids, value = TRUE)[1]); metalearner &lt;- h2o.getModel(se@model$metalearner$name),然后我手动计算了 AUC