feat(14): Forecasting Engine — BAU Track#21
Open
shiniguchi wants to merge 18 commits intomainfrom
Open
Conversation
…e .gstack/ CSO audit findings: - Pin cloudflare/wrangler-action to v3.9.0 SHA (deploy.yml) - Pin supabase/setup-cli to v1.6.0 SHA (migrations.yml, tests.yml) - Update postcss 8.5.9 → 8.5.12 (fixes GHSA-qx2v-qp2m-jg93) - Add .gstack/ to .gitignore (security reports stay local)
Decisions: y=NaN + is_open regressor for closed days, 200 sample paths with latest-run-only retention, 3-tier weather cascade (actual → forecast → climatology with 2021-01-01 Bright Sky backfill), env-var-only feature flags (feature_flags table deferred to Phase 17).
Investigates statsmodels SARIMAX/ETS, prophet 1.3, statsforecast Theta, sample-path generation patterns, exog matrix assembly, and closed-day handling strategies for the nightly forecast pipeline. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…, cron jobs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
D-01: zero_closed_days() forces yhat/yhat_lower/yhat_upper=0 for closed dates in exog model predictions (SARIMAX, Prophet). D-03: build_open_day_series() filters training data to open days only; map_open_predictions_to_calendar() maps predictions back to calendar dates with 0 for closed days (ETS, Theta, Naive). Also adds scripts/__init__.py to make the package importable.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…uard - sarimax_fit.py: fit_sarimax() with configurable ARIMA + seasonal order, FCS-06 exog drift assertion, simulate() for sample paths, weather_source provenance signature - 3 smoke tests: shape validation, exog column assertion, numeric dtype check
- prophet_fit.py: fit_prophet() with C-04 yearly_seasonality=False, 9 regressor columns, NaN guard on future regressors, predictive_samples() for posterior sample paths - 2 smoke tests: shape + yearly_seasonality verification, NaN rejection
ETS(A,A,A) with weekly seasonality via statsmodels ETSModel. Returns point forecast (yhat/lower/upper) + simulated sample paths. Non-exog model: takes clean open-day-only Series.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
forecast_dailytable,forecast_qualitytable,forecast_daily_mv+forecast_with_actual_vwrapper view,weather_climatologylookup, pg_cron forecast MV refresh (03:30 UTC), weeklyyhat_samplesjanitorscripts/forecast/: 5 model fits (SARIMAX, Prophet, ETS, Theta, Naive same-DoW), shared exog builder with 3-tier weather cascade, closed-day handling, sample path bootstrap, forecast writer, last-7-day evaluator, orchestrator (run_all.py), weather history backfillforecast-refresh.ymlat 01:00 UTC withworkflow_dispatchfor manual rerunsCloses requirements FCS-01 through FCS-11.
Test plan
python -m pytest scripts/forecast/tests/ -v— all tests pass (requirespip install -r scripts/forecast/requirements.txt)tenant_id; Guard 8: no cron overlap)supabase db pushapplies all 6 migrations without errorworkflow_dispatchofforecast-refresh.ymlcompletes <15 minforecast_with_actual_vreturns rows scoped to JWTrestaurant_idforecast_qualitypopulated after first nightly run