Retail Demand Forecasting and Statistical Modelling

Dunnhumby The Complete Journey · Independent Forecasting Study

This independent study investigates grocery purchasing histories through data engineering, weekly forecasting and comparative statistical evaluation. Ten forecasting methods are assessed using chronological training, validation and test periods, with future work examining how forecasts inform inventory replenishment decisions.

Data and interpretation notice. The recorded quantities reflect purchases by participating households, not complete supermarket demand. The source data does not contain confirmed supplier lead times, inventory balances or replenishment decisions. Future inventory analysis will use explicitly synthetic assumptions.

Work Demonstrated

1. Data Engineering & Analysis

A Python-based data preparation workflow transforms grocery transaction records into daily and weekly SKU-level purchase series, supported by data validation and exploratory analysis of purchasing patterns.

Overview

Transaction records are processed into daily and weekly purchase histories for 12 selected grocery products. Exploratory diagnostics examine trends, autocorrelation and potential seasonal patterns.

1.1 Source & Preparation

Product metadata, data preparation and research-sample provenance.

Product ID Commodity Subcategory Pack size
Loading product catalogue…
1.2 Temporal Aggregation

Daily and weekly purchase quantities with chronological training, validation and test partitions.

Loading observed data…
1.3 Time-Series Diagnostics

Investigate underlying trends, autocorrelation and potential recurring patterns using training observations.

Trend Analysis

Loading diagnostics…

2. Forecasting Methodology

Developed a comparative forecasting framework encompassing ten statistical and time-series methods, including naïve forecasting, regression-based approaches, exponential smoothing, and Auto-ARIMA.

Overview

Ten statistical forecasting methods are formulated and implemented, covering naïve approaches, regression, exponential smoothing and ARIMA. Each method produces forecasts across horizons of 1–4 weeks.

Common mathematical notation Shared across the forecasting methods

Equations are written for one SKU at a time; the SKU index is omitted for clarity.

yt
Observed purchase quantity in week \(t\).
ŷt+h|t
Forecast for week \(t\)+\(h\), issued using observations available through week \(t\).
t
Forecast origin: the latest observed week.
h
Forecast horizon, \(h\) ∈ {1, 2, 3, 4} weeks.
2.1 Naïve and Averaging Methods

Direct forecasting through observation repetition, historical averaging, and lag-based selection.

Last Observed

Model description

Uses the most recent observed weekly purchase quantity as the forecast for every horizon. As the rolling origin advances, the forecast is updated with the latest observation.

Mathematical formulation
\[\hat{y}_{t+h\mid t}=y_t\]
Model configuration

No parameters require tuning or estimation.

2.2 Trend and Seasonal Regression Methods

Trend estimation using linear regression, with optional seasonal adjustment based on historical patterns.

Linear Trend

Model description

Uses linear regression to estimate whether weekly purchase quantities are increasing or decreasing over time. The estimated trend is extended into future weeks to generate forecasts.

Mathematical formulation
\[\hat{y}_{t+h\mid t}=\hat a_t+\hat b_t(n_t-1+h)\]

where

\(\hat a_t\)
Estimated intercept using the current rolling window.
\(\hat b_t\)
Estimated slope (change in purchases per week) using the current rolling window.
\(n_t\)
Number of observations in the regression window (up to 26); time indices start at zero.
Model configuration

Regression coefficients (\(\hat a_t,\hat b_t\)): Estimate the intercept and slope using ordinary least squares over the latest 26 observed weeks.

2.3 Exponential Smoothing Methods

Recursive estimation of the underlying level, with extensions for trend, damping, and seasonality.

Simple Exponential Smoothing

Model description

Uses exponential smoothing to estimate the underlying level of weekly purchases, giving greater weight to more recent observations. The estimated level is updated as new observations become available and used to forecast future purchases.

Mathematical formulation
\[\hat{y}_{t+h\mid t}=\ell_t\]

where

\(\ell_t\)
Smoothed level after observing week \(t\).
Show level update equation
Level update (\(\ell_t\))
\[\ell_t=\alpha y_t+(1-\alpha)\ell_{t-1}\]

where

\(\alpha\)
Level smoothing coefficient.
Model configuration

Level smoothing coefficient (\(\alpha\)): Estimate statistically during model fitting.

2.4 ARIMA Models

Autoregressive and moving-average structures, optional differencing, and automatic model selection.

Auto-ARIMA

Model description

Uses autoregressive (AR) and moving-average (MA) components, with differencing when required, to model patterns in weekly purchases. The selected model uses relationships between past observations and forecast errors to predict future purchase quantities.

Mathematical formulation
\[(p^*,d^*,q^*)=\underset{(p,d,q)\in\mathcal C}{\arg\min}\;\operatorname{AICc}(p,d,q)\]

where

\(p,d,q\)
Candidate autoregressive, differencing and moving-average orders.
\(\mathcal C\)
Set of candidate structures considered by the stepwise procedure.
\(\operatorname{AICc}\)
Akaike Information Criterion with small-sample correction.
\(p^*,d^*,q^*\)
Orders selected for the SKU.
Model configuration

Model orders (\(p,d,q\)): Select automatically through a stepwise search using the corrected Akaike Information Criterion (AICc).

Model coefficients: Estimate statistically for the selected ARIMA specification.

Configuration rules and selected parameters are reported in Section 3. Auto-ARIMA is non-seasonal; Holt-Winters and the seasonal-index approach explicitly investigate short repeating cycles, without claiming those cycles are proven.

3. Hyperparameter Tuning

Implemented SKU-specific hyperparameter tuning using rolling-origin validation to select forecasting model configurations based on predictive accuracy across multiple forecast horizons.

Overview

Forecasting methods are configured individually for each product through validation-based selection, statistical parameter estimation or information-criterion optimisation, as appropriate. The selected configurations are subsequently used for test evaluation.

3.1 Tuning Protocol

Method-specific configuration searches, coefficient fitting and model selection.

TrainingWeeks 2–73Initial fitting
ValidationWeeks 74–87Configuration selection
TestWeeks 88–101Final evaluation

Each SKU is configured independently. Candidate configurations are evaluated at rolling validation origins over forecast horizons 1–4; coefficients are fitted using historical observations available at each origin. Different methods use different selection procedures, as shown below.

Method-specific tuning

Select a method family to see what is searched, fitted or held fixed.

Last Observed
Fixed rule

Uses the latest observed quantity. No configuration search or fitted coefficients.

Moving Average
Validation search

Averaging window (\(k\)): Select an integer from 2–72 weeks by minimising pooled rolling-validation WAPE across horizons 1–4.

Lag Forecast
Validation search

Historical lag (\(k\)): Select an integer from 2–72 weeks by minimising pooled rolling-validation WAPE across horizons 1–4.

Validation-based selectionsLowest pooled WAPE across horizons 1–4 for searched configurations.
Statistical fittingCoefficients estimated from historical observations, not directly tuned to validation WAPE.
Final evaluationChosen configurations remain fixed for Weeks 88–101; fitting can update as history expands.
3.2 Selected SKU Configurations

Explore selected settings by product and forecasting method.

Selected configuration

Moving Average

Validation search
Selection procedure

4. Forecast Evaluation & Results

Evaluated forecasting performance across twelve grocery SKUs using out-of-sample predictions, multiple accuracy metrics, and horizon-specific comparisons of observed and forecast purchase quantities.

Overview

Forecast accuracy is evaluated across ten methods, 12 products and four prediction horizons. Interactive comparisons and evidence-based interpretations examine predictive performance, generalisation and product-specific differences.

4.1 Evaluation Metrics

Definitions and interpretation of the forecasting accuracy measures used in the evaluation.

Common Mathematical Notation
\(y_i\)
Observed purchase quantity for evaluated prediction \(i\).
\(\hat y_i\)
Forecast quantity for the corresponding target week.
\(N\)
Number of evaluated forecast–observation pairs.

Weighted Absolute Percentage Error (WAPE)

Metric description

Measures total absolute forecasting error relative to the total observed purchase quantity. A lower value indicates better aggregate accuracy.

Mathematical formulation
\[\mathrm{WAPE}=\frac{\sum_{i=1}^{N}\lvert y_i-\hat y_i\rvert}{\sum_{i=1}^{N}\lvert y_i\rvert}\times 100\%\]
Interpretation

Expressed as a percentage; zero is ideal. The denominator must be non-zero.

4.2 Aggregate Comparison

Compare WAPE, MAE, RMSE and bias across test and validation horizons.

Method Performance

4.3 Forecast vs Observed

Compare observed weekly purchases with rolling-origin forecasts across methods and horizons.

Observed vs Forecast

Loading forecast chart…
4.4 Interpretation

What the forecasting results suggest about generalisation, model complexity and product-level variation.

Generalisation beyond validation

Finding. A method that performs best during configuration selection may not retain its advantage on unseen weeks. Lag Forecast ranks first on validation WAPE at every horizon, but drops to ninth or tenth on the test period.

Lag Forecast · WAPE ranking out of ten methods
1-week horizon#1 Validation#10 Test
2-week horizon#1 Validation#9 Test
3-week horizon#1 Validation#10 Test
4-week horizon#1 Validation#10 Test

Interpretation. The reversal is evidence of limited transfer between evaluation periods, not evidence of a particular cause. A lag that represents earlier purchase behaviour well may be less informative later; the independent test period exposes this risk.

Model complexity and forecasting behaviour

Finding. Extra trend or seasonal components do not consistently improve test accuracy. The comparison below places Simple Exponential Smoothing alongside selected trend and seasonal alternatives across all four horizons.

Selected methods · pooled test WAPE
0%15%30%45%60%1 week2 weeks3 weeks4 weeks
Simple Exponential SmoothingHolt Linear TrendHolt-WintersTrend + Seasonal Index

Interpretation. A more elaborate structure is helpful only when its assumptions are informative for future observations. Recent-level smoothing can remain competitive when additional trend or seasonal components do not translate into lower test error. This comparison does not establish that model complexity itself causes the difference.

Product-specific performance

Finding. No pooled ranking can reveal which method is strongest for every product. The heatmap compares methods within each SKU, so differences in purchase scale do not dominate the colours.

Within-product test WAPE rankings

1 = lowest WAPE among the ten methods for that SKU; 10 = highest. Hover or focus on a cell to see the underlying WAPE. Ties share a rank.

Interpretation. Changing winners across products indicates that a single pooled recommendation may not serve every SKU. Method selection should consider the specific purchase history and forecast horizon, not just aggregate accuracy.

Understanding the magnitude of forecast errors

What a 30–40% WAPE means. Across the evaluated observations, total absolute forecast error is approximately 30–40% of total observed purchase quantity. It does not mean each weekly forecast misses by that percentage.

What may contribute. The measured series records purchases from a sampled household panel, not total retailer demand. Weekly quantities vary, and abrupt changes can be difficult to anticipate from past observations alone. Because WAPE divides absolute errors by observed purchase volume, similar absolute errors can also produce a larger percentage when purchase totals are lower.

What we can conclude. These are plausible contributing factors, not established explanations for any model's error. Testing them would require additional analysis of weekly variability, prediction residuals, product behaviour and potential shifts between the training and evaluation periods.

5. Future Extensions

Explore possible next steps, including machine-learning forecasting or synthetic inventory replenishment experiments.

Overview

This section is reserved for the next research extension. Potential directions include machine-learning forecasting and a synthetic inventory replenishment environment. Neither has been selected or evaluated as part of the current ten-method comparison.

5.1 Planned Environment

Inventory setting

Specify opening stock, review frequency, shelf-life assumptions, lead times and supplier replenishment rules in a fully synthetic but realistic grocery setting.

Ordering policies

Compare alternative replenishment logics, such as simple order-up-to policies, forecast-based review rules, and scenario-driven planning responses.

Operational metrics

Evaluate service level, stockouts, waste, overstocks and cost implications under consistent demand scenarios.

Digital-twin style extension

Use the demand forecasts as one layer inside a broader simulated operational environment, without claiming access to confidential real inventory data.

5.2 Current Status

Planned extension only. No simulated inventory outputs are published on this page yet.
Observed purchase data. The reported forecasts concern a selected household panel, not total store demand. Inventory policies and operational outcomes are not simulated here.