Skip to main content
Open In Colab

Motivation

The AutoARIMA model is widely used to forecast time series in production and as a benchmark. However, the python implementation (pmdarima) is so slow that prevent data scientist practioners from quickly iterating and deploying AutoARIMA in production for a large number of time series. In this notebook we present Nixtla’s AutoARIMA based on the R implementation (developed by Rob Hyndman) and optimized using numba.

Example

Libraries

Useful functions

Data

For testing purposes, we will use the Hourly dataset from the M4 competition.
In this example we will use a subset of the data to avoid waiting too long. You can modify the number of series if you want.
Would an autorregresive model be the right choice for our data? There is no doubt that we observe seasonal periods. The autocorrelation function (acf) can help us to answer the question. Intuitively, we have to observe a decreasing correlation to opt for an AR model.
Thus, we observe a high autocorrelation for previous lags and also for the seasonal lags. Therefore, we will let auto_arima to handle our data.

Training and forecasting

StatsForecast receives a list of models to fit each time series. Since we are dealing with Hourly data, it would be benefitial to use 24 as seasonality.
As we see, we can pass season_length to AutoARIMA, so the definition of our models would be,

Alternatives

pmdarima

You can use the StatsForecast class to parallelize your own models. In this section we will use it to run the auto_arima model from pmdarima.

Prophet

Prophet is designed to receive a pandas dataframe, so we cannot use StatForecast. Therefore, we need to parallize from scratch.

Evaluation

Time

Since AutoARIMA works with numba is useful to calculate the time for just one time series.

Performance

pmdarima (only two time series)

Prophet

For a complete comparison check the complete experiment. Open In Colab