Favorita Store Sales Forecasting: An End-to-End ML Showcase

An open, reproducible forecasting stack on the Corporación Favorita dataset — dbt, BigQuery ML, Vertex AI, and Prefect, wired end to end.

OVERVIEW

A Production Forecasting Stack You Can Read End to End

A public, open-source showcase that takes the Corporación Favorita grocery sales dataset and builds the full forecasting system around it, from raw load to orchestrated training and evaluation.

It is the reference implementation behind our restaurant and retail forecasting work: dbt for the transformation and feature layer, BigQuery ML for fast in-warehouse baselines, Vertex AI for custom models, and Prefect tying the pipeline together.

Every layer is real code in a single repository, so the architecture is something you can read and run rather than a diagram in a slide.

The Challenge

Retail demand forecasting at scale (thousands of store and product combinations) raises the same hard questions every time:

  • How do you turn messy transactional data into clean, reusable features?

  • When is a simple in-warehouse baseline enough, and when do you need a custom model?

  • How do you keep training, prediction, and evaluation reproducible instead of ad hoc?

  • How do you compare models on the metrics operators actually care about?

The showcase answers those questions with one coherent stack instead of a pile of disconnected notebooks.

APPROACH

The Approach

The repository builds the system in clear layers:

  • Data ingestion scripts load the Favorita dataset into BigQuery

  • dbt staging, intermediate, and mart models shape the data and engineer features, with tests and documentation

  • BigQuery ML models provide fast forecasting baselines in pure SQL

  • Vertex AI custom jobs train XGBoost, a scikit-learn random-forest baseline, and ARIMA/SARIMA time-series models

  • Optuna tunes hyperparameters; MLflow tracks every run

  • Kubeflow pipelines on Vertex chain training, evaluation, and registration

  • Prefect flows orchestrate the whole thing on a schedule

Models are compared on MAPE, WAPE, and RMSE so the choice between a BQML baseline and a custom model is made on evidence.

Core architecture:

  • BigQuery as the data and feature warehouse

  • dbt for transformation, feature engineering, tests, and docs

  • BigQuery ML for SQL-native baseline forecasts

  • Vertex AI for custom training (XGBoost, scikit-learn, statsmodels)

  • Optuna for hyperparameter optimization and MLflow for experiment tracking

  • Kubeflow Pipelines for ML DAGs on Vertex

  • Prefect for orchestration, Docker and GitHub Actions for packaging and CI/CD

The same patterns map directly onto the restaurant forecasting build, which is why this exists as a public reference.

Technical Stack

  • dbt

  • BigQuery ML

  • Vertex AI

  • XGBoost

  • Prefect

  • MLflow

  • Docker

  • GitHub

RESULTS

Key Outcomes

  • A complete, reproducible forecasting stack in one repository

  • Both fast SQL baselines and custom models, compared on the same metrics

  • Experiment tracking and pipeline orchestration built in, not bolted on

  • A teaching reference for analytics-engineering and ML patterns

  • A reusable foundation for client retail and demand-forecasting work

Why This Matters

Most forecasting tutorials stop at a single model in a notebook. Real systems need the parts around the model: features, tests, tracking, orchestration, and packaging. This showcase matters because it makes those parts visible and runnable, which helps teams:

  • See how a warehouse-native and a custom-model approach compare in practice

  • Adopt analytics-engineering discipline (tests, docs, version control) for ML

  • Start from a working stack instead of a blank repository

Looking Forward

Planned additions:

  • Probabilistic and quantile forecasts for inventory safety stock

  • Automated retraining triggered by drift detection

  • Promotion and price elasticity features

  • A lightweight serving API for on-demand forecasts

Interested in building something similar?

We help organizations design scalable AI and analytics infrastructure for:

  • forecasting

  • growth analytics

  • operational automation

  • machine learning platforms

  • agentic AI workflows

  • cloud-native data systems

Let’s build systems that turn data into operational leverage.