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#
ADDED—TimeSeriesExperiment.predict_modelinpackages/engine/pycaret/tasks/time_series.py. Reconciles pipeline (deepcopy ifForecastingPipeline; wire bare forecaster via_add_model_to_pipeline), forecast horizon (arg →_fit_state["fh"]→estimator.fh), and exogenous X (arg /datashim →_fit_state["X_test"]). Callsget_predictions_with_intervalsfor predictions; computes test metrics viacalculate_metrics+update_additional_scorer_kwargswheny_testis available. Returns a typedPredictResult. Supportsreturn_pred_int, customfh, customalpha/coveragefor prediction intervals.
ADDED — tests#
ADDED—packages/engine/tests/test_session41_ts_predict_model_drain.py— 8 new tests:- Drain-lock for
predict_model(poisonlegacy.predict_model, verify native). - Metrics DataFrame: 9 columns (
Model+ 8 standard TS metrics). pull()returns the predict_model metrics.return_pred_int=Trueincludes lower / upper columns.- Custom
fh=[1,2,3]produces 3 predictions. - Bare forecaster (no pipeline) gets wired into the experiment's preprocess.
- Object without
.predict→TypeError. - End-to-end
create + predictchain with both legacy verbs poisoned.
- Drain-lock for
INTERNAL#
INTERNAL— Why reuseget_predictions_with_intervals+calculate_metrics. Same reasoning ascross_validatereuse in s40 — these are free functions (no legacy state), already handle the alpha/coverage interval plumbing and metric registry iteration withadditional_kwargs. Re-implementing them on top of bare sktime would either lose interval support or duplicate care code.INTERNAL— Bare forecaster path. When the user passes a bare fitted sktime forecaster (not aForecastingPipeline), we wire it into the experiment's preprocess pipeline via_add_model_to_pipeline. Letsjoblib.dump-ed forecasters from older code work without forcing the user to reconstruct a pipeline.INTERNAL— Thedataparameter shim. Supervisedpredict_modeltakesdataas the second positional arg. TS legacy usedXas the exogenous-data parameter. The native override accepts both —datadefers toXif both are passed;databecomesXotherwise. Keeps the verb signature compatible with how callers might invoke from the supervised side.
Session 41 delta summary#
| Metric | Session 40 end | Session 41 end |
|---|---|---|
| TS verbs drained (out of 6) | 1 (create_model) | 2 (+ predict_model) |
legacy.predict_model callsites for TS | 1 | 0 |
| Engine tests (fast + slow) | 201 | 209 |