0

I am fairly new to h2o and trying to get my head around it. I am currently using automl and from the models on my leaderboard I have decided to use the 3rd model not the leader model.

I do that using the code below and then get the parameters of that specific model. I then manually check the actual parameters that are different from the default ones and use them to define my model.

#choosing the 3rd model from the leaderboard
chosen_model = h2o.get_model(aml.leaderboard.as_data_frame()['model_id'][2])

#getting the model parameters
chosen_model.params

# example result including only some of the parameters 

{'model_id': {'default': None,
  'actual': {'__meta': {'schema_version': 3,
    'schema_name': 'ModelKeyV3',
    'schema_type': 'Key<Model>'},
   'name': 'GBM_grid_1_AutoML_20191007_170602_model_12',
   'type': 'Key<Model>',
   'URL': '/3/Models/GBM_grid_1_AutoML_20191007_170602_model_12'}},
 'training_frame': {'default': None,
  'actual': {'__meta': {'schema_version': 3,
    'schema_name': 'FrameKeyV3',
    'schema_type': 'Key<Frame>'},
   'name': 'automl_training_py_13_sid_ac88',
   'type': 'Key<Frame>',
   'URL': '/3/Frames/automl_training_py_13_sid_ac88'}},
 'validation_frame': {'default': None,
  'actual': {'__meta': {'schema_version': 3,
    'schema_name': 'FrameKeyV3',
    'schema_type': 'Key<Frame>'},
   'name': 'py_15_sid_ac88',
   'type': 'Key<Frame>',
   'URL': '/3/Frames/py_15_sid_ac88'}},
 'nfolds': {'default': 0, 'actual': 5},
 'keep_cross_validation_models': {'default': True, 'actual': False},
 'keep_cross_validation_predictions': {'default': False, 'actual': True},
 'keep_cross_validation_fold_assignment': {'default': False, 'actual': False},  etc.


# pasting the actual parameters on my model

model = H2OGradientBoostingEstimator(nfolds=5, keep_cross_validation_models=False, keep_cross_validation_predictions= True, score_tree_interval=5, fold_assignment= 'Modulo', ntrees=51, max_depth=12, min_rows=5.0, stopping_metric='deviance', stopping_tolerance = 0.04867923835112355, seed = 47, distribution='gaussian', learn_rate=0.1, sample_rate=0.5, col_sample_rate = 0.7) 

This is a process I have to repeat many times, as I am running many automls for a project I am currently wokring on.

Is there a code already available on h2o that lets you do that automatically? Or does anyone know a more efficient way?

Thanks a lot in advance!

Marina
  • 3
  • 2

1 Answers1

0

We don't yet have a convenience function to grab non-default parameters from an H2O model in Python, but there's a ticket open for it.

My suggestion is that you just write a function to do this (check all the params to see if the "default" and "actual" values are the same, return non-default ones), so you can re-use it on any model in the future. If you do write a function, please update your post and perhaps we can use your code to complete the task (or feel free to create a pull request). :-)

Erin LeDell
  • 8,704
  • 1
  • 19
  • 35