Skip to content

monitor_predictions

The model-agnostic bring-your-own-predictions entry point. Given either a generic model (any predict_proba / decision_function / predict scorer) or a precomputed predictions array, it runs the lite pipeline — surrogate tree, high-error cohort tree, archetype-lite segments, holdout metrics, drift (PSI) and model-free fairness — treating the model as an opaque scorer. See the BYO-model example.

In short

  • monitor_predictions treats the model as an opaque scorer, or takes predictions= alone.
  • It returns a ProfilingResult whose backend is lite_model or lite_predictions.
  • For a model mli has an adapter for, call fit_profiler instead.
  • The positive class and the decision cut are resolved once and stored on result.target_ and result.threshold_.

Prefer fit_profiler for natively supported models

For a model mli has an adapter for — CatBoost / LightGBM / XGBoost / scikit-learn ensembles (leaf-space), or HistGradientBoosting / DecisionTree / EBM / RuleFit / scikit-learn linear & GLM families (SHAP-space) — call fit_profiler directly for native profiling and requested optional analysis. Geometry and rule support vary by family; a binary y profiles the model's positive class (classes_[1]) without a mask. See Supported models. Tasks: binary, multiclass, and regression (task_type=).

Positive class and decision threshold

Both entry points resolve a binary run's positive class once (positive_class=, else the model's classes_[1], else True / 1 / the last of two sorted labels — the last with a warning) and its decision cut once (served_threshold= for a deployed operating point, else decision_threshold=: a float, "f1" / "f<beta>" to tune, or None — the default — for the model's own decision). The answers are stored on result.target_ and result.threshold_. positive_class= names a label by ml4's rule — string or numeric form, so "True" names True and "1.0" names 1.0 — and a y showing a single unconventional label (say, all "no") with nothing naming the positive class is refused rather than guessed.

monitor_predictions

monitor_predictions(
    *,
    X: DataFrame,
    y: ndarray | Series | None = None,
    model: Any | None = None,
    predictions: ndarray | Series | None = None,
    X_valid: DataFrame | None = None,
    y_valid: ndarray | Series | None = None,
    predictions_valid: ndarray | Series | None = None,
    X_test: DataFrame | None = None,
    y_test: ndarray | Series | None = None,
    predictions_test: ndarray | Series | None = None,
    reference_df: DataFrame | None = None,
    sensitive_features: DataFrame | Series | None = None,
    task_type: TaskType = BINARY,
    mode: Literal[
        "surrogate", "error", "archetype_lite", "all"
    ] = "all",
    decision_threshold: float | str | None = None,
    served_threshold: float | None = None,
    positive_class: Any = None,
    surrogate_engine: "EngineKey" = "lgbm",
    random_state: int = 42
) -> ProfilingResult

Interpret a model's predictions — the model-agnostic lite path.

The standalone monitoring / "bring-your-own-predictions" entry point: given either a generic model (any object exposing predict_proba / decision_function / predict) or a precomputed predictions array, build a surrogate decision tree, high-error cohort tree, archetype-lite segments, holdout metrics, drift (PSI) and model-free fairness — without ever needing the model's internals. This is the standalone / external-model-monitoring path for scorers mli has no native adapter for.

For models mli recognises natively (CatBoost / LightGBM / XGBoost / sklearn ensembles / trees / HGB) prefer :func:parleml_mli.fit_profiler: it delivers the full surface (exact SHAP, leaf-space archetypes, rules, PDP/ICE, counterfactuals). monitor_predictions treats the model as an opaque scorer and works for any estimator.

Parameters:

Name Type Description Default
X DataFrame

Feature matrix and (optional) ground truth. y unlocks the error-tree branch and holdout metrics; without it the error tree is skipped (capabilities.error_tree stays False).

required
y DataFrame

Feature matrix and (optional) ground truth. y unlocks the error-tree branch and holdout metrics; without it the error tree is skipped (capabilities.error_tree stays False).

required
model Any | None

Any estimator exposing predict_proba / decision_function / predict. Mutually exclusive with predictions.

None
predictions ndarray | Series | None

Score array aligned with X (positive-class probability for binary; raw target for regression). Mutually exclusive with model.

None
X_valid DataFrame | None

Holdout splits for the evaluation report. In the predictions-only branch supply the matching predictions_* alongside X_* / y_*; missing scores simply leave that split off the report.

None
y_valid DataFrame | None

Holdout splits for the evaluation report. In the predictions-only branch supply the matching predictions_* alongside X_* / y_*; missing scores simply leave that split off the report.

None
predictions_valid DataFrame | None

Holdout splits for the evaluation report. In the predictions-only branch supply the matching predictions_* alongside X_* / y_*; missing scores simply leave that split off the report.

None
X_test DataFrame | None

Holdout splits for the evaluation report. In the predictions-only branch supply the matching predictions_* alongside X_* / y_*; missing scores simply leave that split off the report.

None
y_test DataFrame | None

Holdout splits for the evaluation report. In the predictions-only branch supply the matching predictions_* alongside X_* / y_*; missing scores simply leave that split off the report.

None
predictions_test DataFrame | None

Holdout splits for the evaluation report. In the predictions-only branch supply the matching predictions_* alongside X_* / y_*; missing scores simply leave that split off the report.

None
reference_df DataFrame | None

Drift baseline (defaults to X_valid when supplied).

None
sensitive_features DataFrame | Series | None

Group memberships aligned with X for model-free per-group rates (stored on result.meta['fairness_lite']). The adverse-impact ratio reads against the highest-rate group of at least :attr:parleml_mli.FairnessConfig.min_group_size rows, as the native path's :func:~parleml_mli.explanations.compute_fairness does.

None
task_type TaskType

Lite-pipeline knobs (see :func:parleml_mli.fit_profiler for the shared semantics).

BINARY
mode TaskType

Lite-pipeline knobs (see :func:parleml_mli.fit_profiler for the shared semantics).

BINARY
surrogate_engine TaskType

Lite-pipeline knobs (see :func:parleml_mli.fit_profiler for the shared semantics).

BINARY
random_state TaskType

Lite-pipeline knobs (see :func:parleml_mli.fit_profiler for the shared semantics).

BINARY
decision_threshold float | str | None

Binary decision cut, resolved once by :func:parleml_mli.core.threshold.resolve_threshold on the (scored or supplied) predictions: None (default) keeps the model's own decision (0.5 on the positive-class probability), a float is used as given, "f1" / "f<beta>" tunes a cut against y. Stored on result.threshold_.

None
served_threshold float | None

The deployed model's published cut; wins over decision_threshold.

None
positive_class Any

The positive label of a binary y, resolved once by :func:parleml_mli.core.target.resolve_target (model.classes_[1] when the model has classes, else True / 1 / the last sorted label) and stored on result.target_. predictions must be this class's probability.

None

Returns:

Type Description
ProfilingResult

Carries a :class:~parleml_mli.result.Capabilities stamp (backend is "lite_model" or "lite_predictions") so consumers can grey out tabs the lite path cannot power.

Next