是否可以从两个堆叠的集成模型制作一个堆叠的集成模型?

时间:2019-03-27 13:40:18

标签: r h2o

我想用h2o::h2o.automl函数创建两个已经集成的模型。

# Fit models
all_models_h2o_s1 <- h2o::h2o.automl(y = "sr_elec",
                                  training_frame = df_train_d_h2o,
                                  max_models = 2,
                                  max_runtime_secs = 60*60*24, # 1 day
                                  stopping_metric = "deviance",
                                  sort_metric = "deviance",
                                  seed = 1, # this is the only diference
                                  nfolds = 5,
                                  keep_cross_validation_predictions = TRUE)
all_models_h2o_s2 <- h2o::h2o.automl(y = "sr_elec",
                                     training_frame = df_train_d_h2o,
                                     max_models = 2,
                                     max_runtime_secs = 60*60*24, # 1 day
                                     stopping_metric = "deviance",
                                     sort_metric = "deviance",
                                     seed = 2, # this is the only diference
                                     nfolds = 5,
                                     keep_cross_validation_predictions = TRUE)

# Get best models
model_l1_s1 <- all_models_h2o_s1@leader
model_l1_s2 <- all_models_h2o_s2@leader

# Model types
model_l1_s1@model_id # StackedEnsemble_AllModels_AutoML_20190327_141553
model_l1_s2@model_id # StackedEnsemble_AllModels_AutoML_20190327_142026

# Ensemble models
ensemble <- h2o::h2o.stackedEnsemble(y = "sr_elec",
                                     training_frame = df_train_d_h2o,
                                     base_models = list(model_l1_s1, model_l1_s2))

给出的错误是:

water.exceptions.H2OIllegalArgumentException: Base model does not use cross-validation: 0

water.exceptions.H2OIllegalArgumentException: Base model does not use cross-validation: 0
    at hex.StackedEnsembleModel.checkAndInheritModelProperties(StackedEnsembleModel.java:368)
    at hex.ensemble.StackedEnsemble$StackedEnsembleDriver.computeImpl(StackedEnsemble.java:234)
    at hex.ModelBuilder$Driver.compute2(ModelBuilder.java:218)
    at water.H2O$H2OCountedCompleter.compute(H2O.java:1395)
    at jsr166y.CountedCompleter.exec(CountedCompleter.java:468)
    at jsr166y.ForkJoinTask.doExec(ForkJoinTask.java:263)
    at jsr166y.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:974)
    at jsr166y.ForkJoinPool.runWorker(ForkJoinPool.java:1477)
    at jsr166y.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104)

Error: water.exceptions.H2OIllegalArgumentException: Base model does not use cross-validation: 0

版本:

packageVersion(pkg = "h2o")
[1] ‘3.22.1.1’
R.Version()
$platform
[1] "x86_64-w64-mingw32"

$arch
[1] "x86_64"

$os
[1] "mingw32"

$system
[1] "x86_64, mingw32"

$status
[1] ""

$major
[1] "3"

$minor
[1] "5.3"

$year
[1] "2019"

$month
[1] "03"

$day
[1] "11"

$`svn rev`
[1] "76217"

$language
[1] "R"

$version.string
[1] "R version 3.5.3 (2019-03-11)"

$nickname
[1] "Great Truth"

1 个答案:

答案 0 :(得分:0)

否,当前不支持此功能,但我创建了ticket来支持它。我还没有尝试过,但是如果您使用blending_frame参数而不是依靠交叉验证的基本模型,您也许可以使它工作。