feat(forecast): feature-aware forecasting foundation — shared feature-frame contract#241
Conversation
…-frame contract (#238)
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Sorry @w7-mgfcode, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
Implements
PRPs/PRP-29-feature-aware-forecasting-foundation.md— the first PRP of the Advanced ML Model Zoo sequence (MLZOO-A). Closes #238.What
Consolidation + contracts + tests + docs only — no new model, no new dependency, no migration, no API/schema/WebSocket change. User-visible behaviour is identical.
app/shared/feature_frames/package — the single source of truth for the regression feature-frame contract: pinned constants (EXOGENOUS_LAGS,HISTORY_TAIL_DAYS), the canonical column set + order, theFutureFeatureFramecarrier, the leakage-safe pure builders (build_calendar_columns,build_long_lag_columns), and theFeatureSafetytaxonomy. Leaf-level — imports nothing fromapp/features/**(enforced by an AST-walk test)._REGRESSION_FEATURE_COLUMNS(forecasting) andcanonical_feature_columns()(scenarios) were physically duplicated and kept in sync only by an integration-test side-effect. Both slices now import the one shared definition; a column-order mismatch is structurally impossible.BaseForecaster.requires_features: ClassVar[bool]—Falsefor the baselines,TrueforRegressionForecaster.ForecastingService.train_model/predictbranch on this flag instead of amodel_typestring check.scenarios/feature_frame.pyimports + re-exports the shared contract (via__all__); keeps only the assumption-driven, DB-touching parts.forecasting/service.py— pure_assemble_regression_rowshelper extracted so the historical-frame leakage spec needs no DB.app/shared/feature_frames/tests/test_leakage.py(shared builders) +app/features/forecasting/tests/test_regression_features_leakage.py(historical builder); backtesting loud-fail guard test pins that feature-aware backtesting raises until PRP-MLZOO-B.examples/models/feature_frame_contract.md; additivemodel_interface.mdupdate.Validation
pytest -m "not integration"— 1306 passedpytest -m integration app/features/scenarios/ app/features/forecasting/— 28/28 (incl. the empty-assumptionmodel_exogenouszero-delta drift detector)grep _REGRESSION_FEATURE_COLUMNS app/— empty (single source of truth)test_regression_forecaster.pypass with no editsNotes
The MLZOO-B/C/D sequence (LightGBM/sklearn first model, XGBoost/Prophet, frontend/registry/explainability) is gated on this PR merging — see
PRPs/INITIAL/INITIAL-MLZOO-index.md.