Extracting H2O models as MOJOs
Just like POJOs, you can extract models trained using H2O’s AutoML using any of the H2O-supported languages.
In the following sub-sections, we shall learn how to extract the model MOJOs using the Python and R programming languages, as well as see how we can extract model MOJOs using H2O Flow.
Extracting H2O models as MOJOs in Python
Let’s see how we can extract models as MOJOs using Python. We shall use the same Iris flower dataset for running AutoML.
Follow these steps to train models using H2O AutoML. Then, we shall extract the leader model and download it as a MOJO:
- Import the
h2o
module and spin up your H2O server:import h2o h2o.init()
- Import the Iris dataset by passing the appropriate location of the dataset in your system. Execute the following command:
data_frame = h2o.import_file("Dataset/iris.data")
- Set the feature and label names by executing the following command:
features = data_frame.columns...