Skip to content

Repository files navigation

ForecastOps

ForecastOps is an end-to-end demand-forecasting reference system. It demonstrates reproducible data generation, auditable data preparation, time-aware features, backtesting, model artifacts, batch inference, drift monitoring, and API serving.

The included dataset is entirely synthetic and models daily demand across stores and products.

Lifecycle

raw demand events → quality pipeline → feature pipeline → time-based backtest → model artifact + metrics
                                                                  ↓
batch forecast / API serving ← registry metadata ← drift monitor ← incoming data

Quick start

python -m venv .venv
source .venv/bin/activate
pip install -e '.[dev]'

forecastops generate --output data/demand.csv
forecastops train --input data/demand.csv --artifact-dir artifacts
forecastops predict --input data/demand.csv --artifact-dir artifacts --output predictions.csv
forecastops monitor --input data/demand.csv --artifact-dir artifacts

Start the API after training:

uvicorn forecastops.api:app --reload

POST /forecast accepts the engineered feature payload used by the model and returns a prediction. POST /forecast/batch supports up to 500 rows. GET /health reports whether an artifact is available.

Set FORECASTOPS_API_KEY to require an X-API-Key header. In a production environment, also set FORECASTOPS_ENVIRONMENT=production; the service refuses traffic if a required key is missing.

What is included

  • Deterministic synthetic demand generation for reproducible demos
  • Auditable preparation: identifier normalization, duplicate-event aggregation, daily cadence completion, and per-series outlier capping
  • Data-quality report stored in artifact metadata: repaired rows, imputed dates, capped values, series count, and source date range
  • Lag, 7/28-day rolling demand, intermittency, calendar, product, store, and series-age features
  • Time-based holdout evaluation with MAE, RMSE, MAPE, and WAPE
  • Versioned model artifact and JSON metadata registry
  • SHA-256 artifact integrity manifest and rolling-origin backtests
  • Batch prediction export
  • Feature-distribution monitoring using Population Stability Index (PSI)
  • FastAPI health, single-row, and batch prediction endpoints
  • API-key protection, Docker healthcheck, Make targets, and GitHub Actions

Production notes

This project uses local files to keep the reference implementation portable. It is production-oriented, not a complete production deployment: replace the local artifact directory with a managed registry, schedule retraining through an orchestrator, route metric and drift events to observability tooling, use a secrets manager, and place the API behind network controls and identity-aware authentication.

License

MIT

About

End-to-end demand forecasting with training, backtesting, batch inference, drift monitoring, and API serving.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages