4

"After running the following Code…"

gbm = h2o.get_model(sorted_final_grid.sorted_metric_table()['model_ids'][0])

params = gbm.params
new_params = {"nfolds":5, "model_id":None}
for key in new_params.keys():
    params[key]['actual'] = new_params[key] 
gbm_best = H2OGradientBoostingEstimator()
for key in params.keys():
    if key in dir(gbm_best) and getattr(gbm_best,key) != params[key]['actual']:
        setattr(gbm_best,key,params[key]['actual'])

"I get the following error…H2OTypeError: 'training_frame' must be a valid H2OFrame!

It is a valid H2OFrame as I have not only imported using the import_file but also ran successfully all the GBM hyperparameter tuning code until I ran into this error.

I am using Python 3.6. I have been following this particular notebook https://github.com/h2oai/h2o-3/blob/master/h2o-docs/src/product/tutorials/gbm/gbmTuning.ipynb "

Jeff King
  • 41
  • 2
  • Please see this on how to create a minimal reproducible example and please update your post to include the code, thanks!: https://stackoverflow.com/help/minimal-reproducible-example If you can remove all extra, non-essential code from the notebook code and paste here, that would great. – Erin LeDell May 13 '20 at 08:39

1 Answers1

0

You will need to set training_frame and validation_frame to None in new_params. Try using the code below and see if that help.

gbm = h2o.get_model(sorted_final_grid.sorted_metric_table()['model_ids'][0])

params = gbm.params
new_params = {"nfolds":5, "model_id":None, "training_frame":None, "validation_frame":None, 
              "response_column":None, "ignored_columns":None}
for key in new_params.keys():
    params[key]['actual'] = new_params[key] 
gbm_best = H2OGradientBoostingEstimator()
for key in params.keys():
    if key in dir(gbm_best) and getattr(gbm_best,key) != params[key]['actual']:
        setattr(gbm_best,key,params[key]['actual']) 

I will get the tutorial you referred to updated.

  • Thank you so much. What a relief!!! I'd appreciate it if you would update the code in the respective notebook as well. – Jeff King Jun 23 '20 at 21:02