0

I saved H2O model using model.download_mojo(path="path", get_genmodel_jar=True). I want retrieve that model to use in jupyter notebook again. How can I do that? Thanks.

Neo
  • 4,200
  • 5
  • 21
  • 27

1 Answers1

2

You can do this:

data = h2o.import_file(path='training_dataset.csv')
original_model = H2OGeneralizedLinearEstimator()
original_model.train(x = ["Some column", "Another column"], y = "response", training_frame=data)

path = '/path/to/model/directory/model.zip'
original_model.download_mojo(path)

And then in a new notebook do this:

path = '/path/to/model/directory/model.zip'
imported_model = h2o.import_mojo(path)
new_observations = h2o.import_file(path='new_observations.csv')
predictions = imported_model.predict(new_observations)


[ Taken from this page in the documentation:

TomKraljevic
  • 3,661
  • 11
  • 14
  • Thank you TomKraljevic, I could import the model, but this was a random forest model. Later I am passing this model to H2OTree method. But I get an error that this is not a tree based model. I think it gets imported as MOJO model. Is there any way to import tree based model. – Neo Aug 09 '19 at 14:59
  • Instead of exporting a MOJO, you can call saveModel and loadModel. But the H2O-3 software version number needs to be the same. – TomKraljevic Aug 10 '19 at 15:32
  • Yes, but this model was exported as mojo in past. – Neo Aug 12 '19 at 18:04