← Back to blog
2026-04-25

Session 41: Phase 5c: drain TimeSeriesExperiment.predict_model

Engineering log for session 41.

The second TS verb is fully native. exp.predict_model(forecaster) no longer touches legacy.predict_model — predictions go through the standalone get_predictions_with_intervals helper and metrics are computed against _fit_state["y_test"] via the standalone calculate_metrics utility.

ADDED — engine#

  • ADDEDTimeSeriesExperiment.predict_model in packages/engine/pycaret/tasks/time_series.py. Reconciles pipeline (deepcopy if ForecastingPipeline; wire bare forecaster via _add_model_to_pipeline), forecast horizon (arg → _fit_state["fh"]estimator.fh), and exogenous X (arg / data shim → _fit_state["X_test"]). Calls get_predictions_with_intervals for predictions; computes test metrics via calculate_metrics + update_additional_scorer_kwargs when y_test is available. Returns a typed PredictResult. Supports return_pred_int, custom fh, custom alpha / coverage for prediction intervals.

ADDED — tests#

  • ADDEDpackages/engine/tests/test_session41_ts_predict_model_drain.py — 8 new tests:
    • Drain-lock for predict_model (poison legacy.predict_model, verify native).
    • Metrics DataFrame: 9 columns (Model + 8 standard TS metrics).
    • pull() returns the predict_model metrics.
    • return_pred_int=True includes lower / upper columns.
    • Custom fh=[1,2,3] produces 3 predictions.
    • Bare forecaster (no pipeline) gets wired into the experiment's preprocess.
    • Object without .predictTypeError.
    • End-to-end create + predict chain with both legacy verbs poisoned.

INTERNAL#

  • INTERNALWhy reuse get_predictions_with_intervals + calculate_metrics. Same reasoning as cross_validate reuse in s40 — these are free functions (no legacy state), already handle the alpha/coverage interval plumbing and metric registry iteration with additional_kwargs. Re-implementing them on top of bare sktime would either lose interval support or duplicate care code.
  • INTERNALBare forecaster path. When the user passes a bare fitted sktime forecaster (not a ForecastingPipeline), we wire it into the experiment's preprocess pipeline via _add_model_to_pipeline. Lets joblib.dump-ed forecasters from older code work without forcing the user to reconstruct a pipeline.
  • INTERNALThe data parameter shim. Supervised predict_model takes data as the second positional arg. TS legacy used X as the exogenous-data parameter. The native override accepts both — data defers to X if both are passed; data becomes X otherwise. Keeps the verb signature compatible with how callers might invoke from the supervised side.

Session 41 delta summary#

MetricSession 40 endSession 41 end
TS verbs drained (out of 6)1 (create_model)2 (+ predict_model)
legacy.predict_model callsites for TS10
Engine tests (fast + slow)201209