Forecasting Intermittent Demand
Learn how to forecast sporadic demand patterns for inventory management.
Introduction
Forecasting intermittent demand (demand that contains many zero values) can be challenging, especially when performance and accuracy are paramount. In this tutorial, we demonstrate how to handle intermittent demand data using TimeGPT. We use a subset of the M5 dataset that captures food item sales in a California store, including exogenous variables like selling price and daily events.
TimeGPT delivers:
- An impressive Mean Absolute Error (MAE) of 0.49, a 14% improvement over the best statistical model specifically designed for intermittent series.
- Quick inference times (approximately 6.8 seconds for prediction), slightly slower (~1 second) than statistical models but highly accurate.
TimeGPT significantly enhances accuracy for intermittent demand forecasting, outperforming specialized statistical alternatives.
Key Features
Performance
Data Preview
Here’s a quick look at the data structure. The dataset tracks food item demand along with exogenous variables (e.g., selling price, event types):
unique_id | ds | y | sell_price | event_type_Cultural | event_type_National | event_type_Religious | event_type_Sporting |
---|---|---|---|---|---|---|---|
FOODS_1_001 | 2011-01-29 | 3 | 2.0 | 0 | 0 | 0 | 0 |
FOODS_1_001 | 2011-01-30 | 0 | 2.0 | 0 | 0 | 0 | 0 |
FOODS_1_001 | 2011-01-31 | 0 | 2.0 | 0 | 0 | 0 | 0 |
FOODS_1_001 | 2011-02-01 | 1 | 2.0 | 0 | 0 | 0 | 0 |
FOODS_1_001 | 2011-02-02 | 4 | 2.0 | 0 | 0 | 0 | 0 |
Figure 1: Visualization of intermittent demand data
Step 1: Environment Setup
You’ll need packages like pandas
, numpy
, and nixtla
before starting.
Using an Azure AI endpoint
To use an Azure AI endpoint, specify the base_url
parameter:
Step 2: Load the Dataset
Confirm that the dataset columns match unique_id
, ds
, and y
, plus any exogenous variables (e.g., sell_price
and event details).
Step 3: Transform the Data
Step 4: Forecast with TimeGPT
Available Models in Azure AI
To use Azure AI directly, set model="azureai"
.
Public API models include timegpt-1
and timegpt-1-long-horizon
.
Step 5: Evaluate the Forecasts
MAE for TimeGPT: approximately 0.49
Step 6: Compare with Statistical Models
TimeGPT’s MAE is about 14% lower than the best-performing statistical model.
Step 7: Use Exogenous Variables
Incorporating exogenous event data can further refine predictions.
Final Results
TimeGPT provides a robust solution for forecasting intermittent demand:
• ~14% MAE improvement over specialized models
• Supports exogenous features for enhanced accuracy
By leveraging TimeGPT and combining both internal series patterns and external factors, organizations can achieve more reliable forecasts even for challenging intermittent demands.