【问题标题】:Get specific model in H2O stacked model在 H2O 堆叠模型中获取特定模型
【发布时间】:2017-12-12 13:01:38
【问题描述】:

所以我已经在 H2O 中使用 GridSearch 训练了几个 GBM 模型。

然后我像这样训练了一个集成模型:

from h2o.estimators.stackedensemble import H2OStackedEnsembleEstimator

#List of all models in the GridSearch
all_model_ids=grid_search_gbm.model_ids


ensemble = H2OStackedEnsembleEstimator(
    model_id = 'ensemble_gbm' ,
    base_models = all_model_ids
)

ensemble.train(
    x=training_columns, 
    y=response_column,
    training_frame=train,
)

我无法仅从“grid_search_gbm”中提取特定模型并将其输入“H2OStackedEnsembleEstimator()”。有没有办法提取这个?例如“grid_search_gbm”中的 3 个最佳模型?

【问题讨论】:

    标签: python h2o


    【解决方案1】:

    你试过了吗

    grid_search_gbm.model_ids[:3]
    

    它应该为您提供与

    相同的模型 ID
    grid_search_gbm.sorted_metric_table()['model_ids'][:3]
    

    【讨论】:

    • 但是我不只是得到一个带有 ID 的字符串吗?我想要的是它自己的模型。 Example: grid_search_rf.model_ids[:3] [u'Grid_DRF_py_53_sid_a1ca_model_python_1513162115962_79468_model_11', u'Grid_DRF_py_53_sid_a1ca_model_python_1513162115962_79468_model_4', u'Grid_DRF_py_53_sid_a1ca_model_python_1513162115962_79468_model_7'] I want to predict using the first model, like so somehow, but below is just the string and not the model itself Grid_DRF_py_53_sid_a1ca_model_python_1513162115962_79468_model_11 .predict(test_frame)
    • 我以为您想将变量 all_model_ids 替换为 id 的子集。您可以使用h2o.get_model('a_model_id') 从 id 中获取模型。但是由于您在这里使用了模型 ID:base_models = all_model_ids 我假设您只是想提取特定的模型 ID 以传递给堆栈?
    猜你喜欢
    • 2021-06-08
    • 2018-07-22
    • 2020-01-04
    • 2018-01-19
    • 2019-01-23
    • 2023-03-16
    • 1970-01-01
    • 2016-06-26
    • 1970-01-01
    相关资源
    最近更新 更多