Search code examples
pythonh2o

How to get all base model from a stackedsamble in h2o


I used H2O's automl on my dataset, and the top model is a stackedensemble model. I like to get all basemodels with it's parameters of this stacked model. How do I get this models?


Solution

  • You can use aml.leader to get the top model or you can use get_best_model to pick the model by some criterium. If you want to pick some specific model from the leaderboard you can use h2o.get_model("model_id") (the model_id is from the leaderboard).

    To get parameters from all the base models you can use the following:

    {base_model: h2o.get_model(base_model).actual_params
     for base_model in h2o.get_model("model_id").base_models}
    

    You might also want to get parameters from the stacked ensemble and the metalearner:

    metalearner_params = h2o.get_model("SE_model_id").metalearner().actual_params
    se_params = h2o.get_model("SE_model_id").actual_params