Skip to main content
Forecast the M5 dataset
In this notebook we show how to use StatsForecast and ray to forecast thounsands of time series in less than 6 minutes (M5 dataset). Also, we show that StatsForecast has better performance in time and accuracy compared to Prophet running on a Spark cluster using DataBricks. In this example, we used a ray cluster (AWS) of 11 instances of type m5.2xlarge (8 cores, 32 GB RAM).

Installing StatsForecast Library

Download data

The example uses the M5 dataset. It consists of 30,490 bottom time series.
unique_iddsy
0FOODS_1_001_CA_12011-01-293.0
1FOODS_1_001_CA_12011-01-300.0
2FOODS_1_001_CA_12011-01-310.0
3FOODS_1_001_CA_12011-02-011.0
4FOODS_1_001_CA_12011-02-024.0
Since the M5 dataset contains intermittent time series, we add a constant to avoid problems during the training phase. Later, we will substract the constant from the forecasts.

Train the model

StatsForecast receives a list of models to fit each time series. Since we are dealing with Daily data, it would be benefitial to use 7 as seasonality. Observe that we need to pass the ray address to the ray_address argument.
StatsForecast and ray took only 5.48 minutes to train 30,490 time series, compared to 18.23 minutes for Prophet and Spark. We remove the constant.

Evaluating performance

The M5 competition used the weighted root mean squared scaled error. You can find details of the metric here.
wrmsse
Total0.677233
Level10.435558
Level20.522863
Level30.582109
Level40.488484
Level50.567825
Level60.587605
Level70.662774
Level80.647712
Level90.732107
Level101.013124
Level110.970465
Level120.916175
Also, StatsForecast is more accurate than Prophet, since the overall WMRSSE is 0.68, against 0.77 obtained by prophet.