Skip to content

feat(forecast): add Prophet-like additive forecasting model (#248)#250

Merged
w7-mgfcode merged 4 commits into
devfrom
feat/forecasting-prophet-like-model
May 19, 2026
Merged

feat(forecast): add Prophet-like additive forecasting model (#248)#250
w7-mgfcode merged 4 commits into
devfrom
feat/forecasting-prophet-like-model

Conversation

@w7-mgfcode
Copy link
Copy Markdown
Owner

Summary

Adds ProphetLikeForecaster — a deterministic, feature-aware additive linear forecasting model (MLZOO-C2). It is a scikit-learn Pipeline of SimpleImputer(median) + Ridge(solver="cholesky") over the canonical 14-column feature frame, plus a model-specific decompose() 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.md ships 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 to forecasting/schemas.py and the ModelConfig union.
  • ProphetLikeForecaster + _PROPHET_LIKE_COMPONENTS constant + ForecastDecomposition dataclass in forecasting/models.py; "prophet_like" added to the ModelType literal and a no-flag model_factory branch.
  • Jobs: _execute_train and _execute_backtest gain a prophet_like branch.
  • Tests: new test_prophet_like_forecaster.py (contract tests + model-specific invariants — additive invariant, NaN tolerance via the imputer, imputer leakage-safety, determinism); prophet_like coverage extended into the forecasting/jobs/backtesting unit tests and the scenarios model_exogenous integration test.
  • Docs: runnable examples/models/prophet_like_additive.py, model_interface.md + feature_frame_contract.md entries, README model-type list.

Pure scikit-learn — ships always-enabled like the regression model: no new dependency, no optional extra, no feature flag. It trains, scenario-re-forecasts, and backtests through the existing requires_features-based dispatch with zero changes to the train/predict/scenarios/backtesting service layers. No pyproject.toml / uv.lock / config.py / routes.py / persistence.py / registry change; no Alembic migration.

Validation

  • ruff check — all checks passed
  • ruff format --check — 294 files already formatted
  • mypy app/ (--strict) — no issues, 272 source files
  • pyright app/ (--strict) — 0 errors
  • pytest -m "not integration" — 1359 passed, 0 failed
  • pytest -m integration (forecasting/scenarios/jobs) — 41 passed, including the new prophet_like model_exogenous test

Closes #248

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.
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @w7-mgfcode, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 46af3e1b-a03c-4864-a4a2-c465d18dde9c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/forecasting-prophet-like-model

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

# 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
@w7-mgfcode w7-mgfcode merged commit 7531eac into dev May 19, 2026
10 checks passed
@w7-mgfcode w7-mgfcode deleted the feat/forecasting-prophet-like-model branch May 19, 2026 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant