What is a MOJO?
A MOJO (Model OBject, Optimized) is a binary zip archive that contains the model’s parameters and tree structures in a compact, optimized format. MOJOs are read at runtime by generic tree-walking code inh2o-genmodel.jar, so they have no size restriction and no compilation step.
Supported algorithms: GBM, DRF, GLM, GAM, GLRM, Deep Learning, K-Means, PCA, Stacked Ensembles, SVM, Word2Vec, Isolation Forest, XGBoost, CoxPH, RuleFit, and all AutoML-generated models.
MOJOs are only supported for encodings that are either default or
enum. MOJO predict cannot parse columns enclosed in double quotes (for example, "2").What is a POJO?
A POJO (Plain Old Java Object) is generated Java source code that embeds the model’s logic directly. The generated class extendsGenModel from h2o-genmodel.jar and can be compiled and loaded into any JVM without any H2O dependency beyond that jar.
Limitations: POJOs are not supported for source files larger than 1 GB. They are also not available for GLRM, Stacked Ensembles, or Word2Vec models.
When to use each
| MOJO | POJO | |
|---|---|---|
| Size restriction | None | Max ~1 GB source |
| Compilation required | No | Yes (javac) |
| Cold scoring speed | 10–40× faster than POJO | Slower on first JVM run |
| Hot scoring speed | 2–3× faster than POJO | ≈10% faster for small binomial/regression models |
| Algorithm support | Broader (includes ensembles) | Narrower |
| Format | Binary .zip | Java .java source file |
The h2o-genmodel.jar dependency
Both formats require h2o-genmodel.jar at compile time and runtime. This jar is the only external dependency needed to score in production — no H2O cluster, no Hadoop, no network.
Download it from a running H2O instance:
h2o-genmodel-ext-xgboost:
Maven pom.xml
Downloading a MOJO
Downloading a POJO
http://localhost:54321.
Scoring with a MOJO in Java
Scoring with a MOJO from the command line
UsePrintMojo to convert a MOJO to a human-readable graph (requires Graphviz):
Frequently asked questions
Are MOJOs and POJOs thread safe?
Are MOJOs and POJOs thread safe?
Yes. Both MOJOs and POJOs are fully thread safe and can be shared across threads.
Can I use a POJO on a Spark cluster?
Can I use a POJO on a Spark cluster?
Yes. The POJO contains only scoring math with no Spark or H2O dependencies. Use it inside a Spark
map that calls the POJO’s predict method for each row and writes the result to a new column.Can I convert a MOJO to ONNX?
Can I convert a MOJO to ONNX?
A subset of MOJOs can be converted using the
onnxmltools Python package. Currently only GBM models are supported, and poisson/gamma/tweedie distributions and categorical splits are not supported. See the onnxmltools project for examples.Why does POJO compilation fail with an IllegalArgumentException?
Why does POJO compilation fail with an IllegalArgumentException?
This happens when the generated
.java source file exceeds 1 GB. Switch to MOJO format, which has no size restriction.Does H2O MOJO have a C++ runtime?
Does H2O MOJO have a C++ runtime?
GBM has a C++ runtime with a C# wrapper for .NET, but this is not part of the open-source offering and requires a support contract.