ModelBase (the base class) or one of its subclasses. These methods are available on every model returned by an estimator’s train() call or loaded via h2o.load_model().
Prediction
predict
Dataset to score. Must contain the same predictor columns used during training.
A custom evaluation function class reference, uploaded to the cluster before scoring.
Reference to a previously uploaded custom metric function (e.g., result of
h2o.upload_custom_metric()). Cannot be specified together with custom_metric.H2OFrame. For classification models, the frame contains:
predict— the predicted class labelp0,p1, … — predicted probabilities for each class
Performance evaluation
model_performance
Compute metrics on this dataset. Takes precedence over
train, valid, and xval flags.Return metrics from the training set.
Return metrics from the validation set.
Return cross-validation metrics.
AUC type for multinomial classification when
test_data is provided. One of: "auto", "none", "macro_ovr", "weighted_ovr", "macro_ovo", "weighted_ovo".MetricsBase) with metric accessors such as .auc(), .mse(), .rmse(), .logloss(), .r2(), .confusion_matrix().
cross_validation_metrics_summary
nfolds >= 2.
Returns an H2OTwoDimTable with mean, standard deviation, and per-fold values for each metric.
Variable importance
varimp
Return results as a Pandas DataFrame when
True. Returns a list of tuples otherwise.varimp_plot
Maximum number of features to display. Shows all features if
None.Run in non-interactive server mode (saves plot instead of rendering).
File path to save the plot image. Requires
server=True or a file extension.Explainability
explain
Dataset to use for generating explanations.
Number of top features to include in each explanation.
explain_row
Dataset containing the row to explain.
Zero-based index of the row to explain.
Model export
download_mojo
Local directory where the MOJO file will be saved.
Also download
h2o-genmodel.jar to the same directory. Required for scoring with the MOJO outside of H2O.Custom filename for the genmodel jar. Defaults to
h2o-genmodel.jar.download_pojo
path is an empty string, the Java source code is printed to stdout instead.
Absolute path to the directory where the POJO
.java file will be saved. When empty, prints to stdout.Also download
h2o-genmodel.jar to the same directory.Custom filename for the genmodel jar.
save_model_details
Directory on the server where the JSON file will be saved.
Overwrite any existing file at the destination.
Custom filename. Defaults to
<model_id>.json.Parameters and metadata
params
actual_params
model_id
type
"classifier", "regressor", or "unsupervised".
have_mojo / have_pojo
Training metadata
scoring_history
Return as a Pandas DataFrame. When
False, returns an H2OTwoDimTable.start_time / end_time / run_time
Cross-validation
is_cross_validated
True if the model was trained with cross-validation.
xvals
SHAP values
predict_contributions
Dataset to compute SHAP values for.
Feature contribution output format for XGBoost.
"Original" (per one-hot encoded feature) or "Compact" (per original feature).Return only the top N highest SHAP contributions. Pass
-1 to sort all contributions in descending order.Return only the bottom N lowest SHAP contributions.
Reference frame for marginal SHAP (when
output_per_reference=False) or baseline SHAP values.H2OFrame with shape (nrows, nfeatures + 1). Each column is the SHAP contribution of one feature; the last column is the model bias.