feat(forecast): add LightGBM feature-aware forecasting model (#242)#243
Conversation
Implements PRP-30 (MLZOO-B) — the first advanced feature-aware forecasting model, LightGBMForecaster wrapping lightgbm.LGBMRegressor, on top of the PRP-29 shared feature-frame contract. - LightGBMForecaster (requires_features=True), structural twin of RegressionForecaster; lightgbm is lazy-imported inside fit() so the module never requires the optional dependency. Deterministic via n_jobs=1 + deterministic=True + force_col_wise=True + random_state. - model_factory lightgbm branch (behind forecast_enable_lightgbm). - ScenarioService.simulate dispatch generalised from a model_type string to bundle.model.requires_features — a LightGBM bundle now takes the genuine model_exogenous re-forecast path. - JobService._execute_train accepts model_type=lightgbm. - ModelBundle.lightgbm_version + registry runtime_info captured best-effort; no migration (runtime_info is JSONB). - LightGBM ships as an optional [project.optional-dependencies] group ml-lightgbm; uv.lock regenerated. No baseline-model change, no API contract change, no migration. Feature-aware backtesting stays loud-fail (deferred to PRP-MLZOO-B.2).
|
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
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Summary
Implements PRP-30 (MLZOO-B) — the first advanced feature-aware forecasting model. Closes #242.
Adds
LightGBMForecaster(wrappinglightgbm.LGBMRegressor) on top of the leakage-safe shared feature-frame contract from PRP-29 (MLZOO-A, #238). LightGBM ships as an optional dependency group so a single-host install stays dependency-light.What changed
LightGBMForecaster(forecasting/models.py) —requires_features=True, structural twin ofRegressionForecaster.lightgbmis lazy-imported insidefit()so importing the module never needs the optional extra. Deterministic vian_jobs=1+deterministic=True+force_col_wise=True+ fixedrandom_state.model_factory— thelightgbmbranch now instantiates the real forecaster (behind the existingforecast_enable_lightgbmflag);NotImplementedErrorremoved.ScenarioService.simulatedispatch generalised from a hard-codedmodel_type == "regression"to capability-basedbundle.model.requires_features, so a LightGBM bundle takes the genuinemodel_exogenouspath.JobService._execute_trainacceptsmodel_type="lightgbm";_execute_backtestunchanged (feature-aware backtesting deferred to PRP-MLZOO-B.2).ModelBundle.lightgbm_version(best-effort save + mismatch-warn on load) and registryruntime_info["lightgbm_version"]. No migration —runtime_infois JSONB.[project.optional-dependencies] ml-lightgbm;uv.lockregenerated; mypy override forlightgbm.*. Coredependencieslist unchanged. CI already runsuv sync --frozen --all-extras --dev.Out of scope (per PRP DECISIONS LOCKED)
No second model (XGBoost/Prophet → MLZOO-C), no hyperparameter search, no feature-aware backtesting (deferred to PRP-MLZOO-B.2 —
test_feature_aware_model_fails_loud_in_backteststays), no migration, no API/WebSocket contract change, no baseline-model change.Minor accuracy fixes folded in
scenarios/service.py(a docstring + an error message) to "feature-aware" so a LightGBM bundle reads correctly — behaviour-preserving forregression.regressionrow to README's supported-model-type list.Validation
test_lightgbm_forecaster.py(13 tests,importorskip-guarded)regression, and the backtest loud-fail guard unchangedexamples/models/advanced_lightgbm.pyexample all verifiedNote: a benign
UserWarning("X does not have valid feature names") surfaces from the sklearn↔LightGBM wrapper — cosmetic, not gated.