feat(forecast): add Prophet-like additive forecasting model (#248)#250
Conversation
Add ProphetLikeForecaster — a deterministic, feature-aware additive linear model (MLZOO-C2). It is a scikit-learn Pipeline of a SimpleImputer(median) + Ridge(solver="cholesky") over the canonical 14-column feature frame, plus a decompose() method that splits any forecast into its additive trend / seasonality / holiday-regressor contributions. Pure scikit-learn — ships always-enabled like the regression model: no new dependency, no optional extra, no feature flag. The model trains, scenario-re-forecasts (method="model_exogenous"), and backtests through the existing requires_features-based dispatch with zero changes to the train/predict/scenarios/backtesting service layers. - ProphetLikeModelConfig (alpha + feature_config_hash); added to the ModelConfig union. - _PROPHET_LIKE_COMPONENTS constant + ForecastDecomposition dataclass. - "prophet_like" added to the ModelType literal + model_factory branch. - jobs _execute_train + _execute_backtest gain a prophet_like branch. - test_prophet_like_forecaster.py: contract tests + model-specific invariants (additive invariant, NaN tolerance, imputer leakage-safety, determinism). - prophet_like coverage extended into the forecasting/jobs/backtesting unit tests and the scenarios model_exogenous integration test.
- examples/models/prophet_like_additive.py: runnable train / predict / decompose example for ProphetLikeForecaster. - model_interface.md: ProphetLikeModelConfig entry + Prophet-like Forecaster formula section (additive decomposition + component column grouping). - feature_frame_contract.md: record prophet_like as an implemented feature-aware model and the worked non-NaN-tolerant imputer example. - README.md: add prophet_like to the Supported Model Types list.
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
|
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 |
# Conflicts: # README.md # app/features/backtesting/tests/test_feature_aware_backtest.py # app/features/forecasting/models.py # app/features/forecasting/tests/test_service.py # app/features/jobs/service.py # app/features/jobs/tests/test_service.py # app/features/scenarios/tests/test_routes_integration.py # examples/models/feature_frame_contract.md # examples/models/model_interface.md
Summary
Adds
ProphetLikeForecaster— a deterministic, feature-aware additive linear forecasting model (MLZOO-C2). It is a scikit-learnPipelineofSimpleImputer(median)+Ridge(solver="cholesky")over the canonical 14-column feature frame, plus a model-specificdecompose()method that splits any forecast into its additive trend / seasonality / holiday-regressor contributions.This is one of two MLZOO-C review units — the sibling
PRPs/PRP-MLZOO-C1-xgboost-model.mdships the XGBoost model on a separate branch. The two are additive and order-independent.Naming honesty: the model is "Prophet-like", not Prophet. It approximates Prophet's additive decomposition shape with a linear model over already-engineered features. It does not add the real
prophet/Stan dependency and does not model changepoint trend, posterior uncertainty intervals, or automatic seasonality discovery. Every docstring and doc section states this plainly.What changed
ProphetLikeModelConfig(alpha+feature_config_hash) added toforecasting/schemas.pyand theModelConfigunion.ProphetLikeForecaster+_PROPHET_LIKE_COMPONENTSconstant +ForecastDecompositiondataclass inforecasting/models.py;"prophet_like"added to theModelTypeliteral and a no-flagmodel_factorybranch._execute_trainand_execute_backtestgain aprophet_likebranch.test_prophet_like_forecaster.py(contract tests + model-specific invariants — additive invariant, NaN tolerance via the imputer, imputer leakage-safety, determinism);prophet_likecoverage extended into the forecasting/jobs/backtesting unit tests and the scenariosmodel_exogenousintegration test.examples/models/prophet_like_additive.py,model_interface.md+feature_frame_contract.mdentries, README model-type list.Pure scikit-learn — ships always-enabled like the
regressionmodel: no new dependency, no optional extra, no feature flag. It trains, scenario-re-forecasts, and backtests through the existingrequires_features-based dispatch with zero changes to the train/predict/scenarios/backtesting service layers. Nopyproject.toml/uv.lock/config.py/routes.py/persistence.py/registrychange; no Alembic migration.Validation
ruff check— all checks passedruff format --check— 294 files already formattedmypy app/(--strict) — no issues, 272 source filespyright app/(--strict) — 0 errorspytest -m "not integration"— 1359 passed, 0 failedpytest -m integration(forecasting/scenarios/jobs) — 41 passed, including the newprophet_likemodel_exogenoustestCloses #248