Skip to content

CV Results API

See OOF predictions for how a run's CVResults are reached.

CVResult

h2ml.core.cv_result.CVResult dataclass

All fold results for a single model run.

Attributes:

Name Type Description
model_name str

Name of the model these folds belong to.

task_type TaskType

TaskType.CLASSIFICATION or TaskType.REGRESSION.

folds list[FoldResult]

Successful FoldResults, one per completed fold.

failed_folds list[int]

Indices of folds that raised during fit/predict and were skipped. A non-empty list means metrics are computed on fewer than the requested number of folds.

y_transform Optional[str]

y-transform the folds were run under; None without a transform.

oof_labels property

True labels paired with oof_predictions (original scale).

Numeric labels use a float array with NaN for unfilled positions. String / object labels use an object array with None for unfilled positions.

oof_predictions property

Out-of-fold predictions assembled across all successful folds.

Classification: positive-class probability (binary) or full probability matrix (multiclass). Regression: predicted values. Positions not covered by any fold (e.g. failed folds) are NaN.

fold_arrays(attr)

Helper to extract a single attribute across all folds.

FoldResult

h2ml.core.cv_result.FoldResult dataclass

Stores the raw arrays produced in one CV fold. Metric computation happens downstream in evaluation/metrics.py.

Attributes:

Name Type Description
fold_id int

Index of this fold within the CV run.

model_name str

Name of the model that produced these predictions.

y_train ndarray

Ground-truth targets for the training rows.

y_test ndarray

Ground-truth targets for the held-out rows.

y_pred_train ndarray

Point predictions on the training rows.

y_pred_test ndarray

Point predictions on the held-out rows.

y_prob_train Optional[ndarray]

Predicted class probabilities on the training rows (None for regressors).

y_prob_test Optional[ndarray]

Predicted class probabilities on the held-out rows (None for regressors).

train_idx ndarray

Row indices used for training — kept for traceability.

test_idx ndarray

Row indices held out — used to reassemble OOF predictions.

fit_time float

Wall-clock seconds spent fitting the model on this fold.

task_type property

Inferred from whether probabilities are present.

Returns a TaskType member, matching CVResult.task_type; string comparisons keep working because TaskType is a str enum.