feat(api,db): add forecast champion selector backend (#353)#354
Conversation
|
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
Summary
Backend-only Forecast Champion Selector — a new
model_selectionvertical slice (issue #353) that, for one (store, product) pair, validates data availability, runs comparable backtests for a set of candidate models, deterministically ranks them, selects a champion with a recommendation confidence, persists an auditable run, and optionally trains/predicts with the winner. Creates the stable backend contract a future UI PRP will consume. No UI, no agent surface, no cloud SDK (by design).Endpoints (all under
/model-selection)GET /availability— coverage, demand, promotion days, recommended split config,ready|limited|unusablePOST /run— availability gate → candidate backtests → ranking → optional train/predict → persisted run (200)GET /{selection_id}— fetch a persisted runGET /{selection_id}/ranking— just the ranking blockPOST /{selection_id}/train-winner— train the championPOST /{selection_id}/predict— forecast with the trained championImplementation notes
model_selection_runtable (JSONB audit snapshots + 6 indexes); migrationb667d321603cchains to headc1d2e3f40512, downgrade drops indexes then table,alembic checkshows no drift.BacktestingService/ForecastingService(fullModelConfigunion + fold-level chart data); sibling services imported lazily, data-platform ORM read at module scope (OpsService precedent).ranking.py(deterministic(wape, smape, abs(bias), mae, model_type)tie-break) +explanations.py(deterministic business summary — no LLM).failed+200,include_baselines=False+store_fold_details=True, horizon match, deterministic ranking,auto_predict⇒auto_train_winner.candidate_results,chart_data) soGETrebuilds the same fold-levelchart_datathat/runreturns.Validation
mypy/pyright0 errors in new code (pre-existing lightgbm/xgboost import noise only; CI installs the extras)test_strict_mode_policy.pygreenCloses #353