Skip to content
Vibhrav Jha.Let’s talk

Retail Sales Forecasting

Demand-model comparison with time order preserved

XGBoost validation RMSLE
0.4841Against Ridge at 0.9884 on the July 17–31, 2017 split.

My contributionData preparation, feature engineering and model comparison.

FieldML & AI / Data Engineering

View repository

Academic experiment

Retail Sales Forecasting project image

The work
behind the interface.

Recorded 0.4841 validation RMSLE with XGBoost versus 0.9884 for Ridge after combining five Favorita datasets on a contiguous time-based split.

  • Python
  • pandas
  • XGBoost
  • LightGBM
  • CatBoost
  • Optuna

The result

XGBoost recorded 0.4841 validation RMSLE versus 0.9884 for Ridge on the July 17–31, 2017 split.

The problem

Combined five Favorita data sources and compared gradient-boosted demand models against Ridge.

A decision worth examining

Preserve time order with a contiguous validation window and persist feature preparation for repeatable comparisons.

Read the README.

View original README
READMEArchitecture, setup and usage

Retail Sales Forecasting

Daily sales forecasts for every store × product family of Corporación Favorita, an Ecuadorian grocery chain, using the Kaggle Store Sales – Time Series Forecasting data. The pipeline runs from exploratory analysis and feature engineering through a leakage-free validation split, three gradient-boosting models with Optuna tuning, and a linear baseline.

Pipeline

flowchart LR
    RAW[train · test · stores<br/>transactions · oil · holidays] --> EDA[EDA &<br/>correlations]
    EDA --> FE[Feature engineering<br/>oil interpolation · calendar ·<br/>holidays · one-hot]
    FE --> SPLIT[Time-based split<br/>train &lt; 2017-07-17<br/>val 07-17 → 07-31]
    SPLIT --> M[LightGBM · CatBoost ·<br/>XGBoost · Ridge]
    M --> TUNE[Optuna tuning]
    TUNE --> SUB[Forecast CSVs<br/>2017-08-01 → 08-15]

Highlights

  • EDA: store-day aggregation, Spearman correlation between sales and transactions, an OLS fit, and monthly and day-of-week transaction trends.
  • Oil prices: resampled to daily frequency, zeros treated as missing, linearly interpolated, then joined in. Correlations with oil are computed per product family.
  • Features: calendar (year, month, day of week, weekend, quarter, day of year), holiday and event flags, promotions, store metadata, and a custom one-hot encoder.
  • Validation: a contiguous hold-out window (2017-07-17 → 2017-07-31), never shuffled, so no future data leaks into training.
  • Models: LightGBM, CatBoost, XGBoost, and a Ridge regression baseline. Each boosted model is tuned with Optuna.
  • Memory-conscious training: dtype downcasting, persisted data splits for crash recovery, and explicit garbage collection on a small VM.

Results

Validation RMSLE (lower is better):

ModelValidation RMSLE
XGBoost0.4841
LightGBM0.4933
CatBoost0.5274
Ridge regression (baseline)0.9884

The tree ensembles roughly halve the linear baseline's error. Tuned hyperparameters are in outputs/.

Tech stack

Python · pandas · NumPy · statsmodels · scikit-learn · LightGBM · CatBoost · XGBoost · Optuna · matplotlib · seaborn

Project structure

Retail-Sales-Forecasting/
├── sales_forecasting.ipynb     # EDA → features → models → tuning
├── forecast_utils.py           # data loading, preprocessing, RMSLE, CSV export
├── outputs/                    # tuned hyperparameters (best_params_*.json)
└── requirements.txt

Running locally

pip install -r requirements.txt

# Download the competition data (requires a Kaggle account + API token)
kaggle competitions download -c store-sales-time-series-forecasting
mkdir -p data/store-sales-time-series-forecasting
unzip store-sales-time-series-forecasting.zip -d data/store-sales-time-series-forecasting

jupyter lab sales_forecasting.ipynb

If the data lives somewhere else, set DATA_DIR. Generated forecasts go to outputs/, or to OUTPUT_DIR if you set it.


Date finished: April 20, 2026

AI Agent Tool Dependency Graph

  1. Aranyaka wildlife-image application interface

    Fullstack

    Aranyaka

  2. DermaNet hackathon prototype showing classification output and a generated explanation

    ML & AI

    DermaNet

  3. AI-generated concept illustration of source documents connected to retrieved evidence and an answer

    ML & AI

    Private-Data RAG

  4. Before It Breaks dashboard separating real weather from synthetic equipment telemetry and estimated costs

    ML & AI

    Before It Breaks

  5. Architecture diagram of simulated stock records flowing through Kafka to HDFS

    Distributed Systems

    Stock Streaming Engine

  6. Vyaya dashboard with clearly labeled synthetic demonstration data

    Fullstack

    Vyaya

  7. Study assistant interface with retrieved source context

    ML & AI

    Fine-Tuning vs. RAG

  8. Architecture diagram of NOAA data, a Cassandra cluster and a query service

    Distributed Systems

    Distributed Weather Data System

  9. Distributed Property Lookup Service project image

    Distributed Systems

    Distributed Property Lookup Service

  10. Architecture diagram connecting MySQL, a gRPC service and HDFS storage

    Distributed Systems

    HDFS & SQL Pipeline

  11. Architecture diagram of Spark processing, SQL and analysis

    Distributed Systems

    Spark Analytics

  12. Multi-Source ELT Pipeline project image

    Data Engineering

    Multi-Source ELT Pipeline

  13. Wisconsin schools in their geographic context — explanatory architecture diagram

    Data Engineering

    GCP Geospatial Pipeline

  14. Chinook Music Store SQL Analytics project image

    Data Engineering

    Chinook Music Store SQL Analytics

  15. Yelp Geospatial Analytics project image

    Data Engineering

    Yelp Geospatial Analytics

  16. E-Commerce Semantic Search Engine project image

    Data Engineering

    E-Commerce Semantic Search Engine

  17. Retail Sales Forecasting project image

    ML & AIViewing

    Retail Sales Forecasting

  18. Making tool dependencies inspectable — explanatory architecture diagram

    ML & AI

    AI Agent Tool Dependency Graph

  19. From public records to operational questions — explanatory architecture diagram

    Data Engineering

    Palantir Foundry and AIP Build Challenge

  20. StudyFlow study-session dashboard

    Fullstack

    StudyFlow

  21. Habit Command Center planning dashboard

    Fullstack

    Habit Command Center

  22. Interfaces across web and mobile — explanatory architecture diagram

    Fullstack

    React Web & Mobile

  23. Startup Scout project image

    Fullstack

    Startup Scout

  24. Inventory-Based Recipe Planner project image

    Fullstack

    Inventory-Based Recipe Planner

  25. Concurrent Word Count and Performance Benchmarking project image

    Data Engineering

    Concurrent Word Count

  26. Data structures matched to their assumptions — explanatory architecture diagram

    Computing Foundations

    Algorithm Design

  27. Campus Navigator project image

    Fullstack

    Campus Navigator

  28. i-Songly: Song Management Engine project image

    Fullstack

    i-Songly

  29. An experiment that can resume — explanatory architecture diagram

    ML & AI

    CIFAR-100 with LeNet

  30. Fashion-MNIST Neural Network Classifier project image

    ML & AI

    Fashion-MNIST Classifier

  31. PCA Eigenfaces and Image Reconstruction project image

    ML & AI

    PCA Eigenfaces

  32. Two routes to the same regression objective — explanatory architecture diagram

    ML & AI

    Lake Mendota Ice Regression

  33. Bayesian Language Detection project image

    ML & AI

    Bayesian Language Detection

  34. Explanatory diagram of the video-fingerprint benchmark: 25 sources, 75 transformed variants and 1,875 comparisons.

    ML & AI

    Video-Fingerprint Benchmark

All projects