Skip to main content
Geographical Hierarchical Forecasting on Australian Tourism Data
In many applications, a set of time series is hierarchically organized. Examples include the presence of geographic levels, products, or categories that define different types of aggregations. In such scenarios, forecasters are often required to provide predictions for all disaggregate and aggregate series. A natural desire is for those predictions to be “coherent”, that is, for the bottom series to add up precisely to the forecasts of the aggregated series. In this notebook we present an example on how to use HierarchicalForecast to produce coherent forecasts between geographical levels. We will use the classic Australian Domestic Tourism (Tourism) dataset, which contains monthly time series of the number of visitors to each state of Australia. We will first load the Tourism data and produce base forecasts using an AutoETS model from StatsForecast, and then reconciliate the forecasts with several reconciliation algorithms from HierarchicalForecast. Finally, we show the performance is comparable with the results reported by the Forecasting: Principles and Practice which uses the R package fable. You can run these experiments using CPU or GPU with Google Colab. Open In Colab

1. Load and Process Data

In this example we will use the Tourism dataset from the Forecasting: Principles and Practice book. The dataset only contains the time series at the lowest level, so we need to create the time series for all hierarchies.
The dataset can be grouped in the following non-strictly hierarchical structure.
Using the aggregate function from HierarchicalForecast we can get the full set of time series.

Split Train/Test sets

We use the final two years (8 quarters) as test set.

2. Computing base forecasts

The following cell computes the base forecasts for each time series in Y_df using the ETS model. Observe that Y_hat_df contains the forecasts but they are not coherent.

3. Reconcile forecasts

The following cell makes the previous forecasts coherent using the HierarchicalReconciliation class. Since the hierarchy structure is not strict, we can’t use methods such as TopDown or MiddleOut. In this example we use BottomUp and MinTrace.
The dataframe Y_rec_df contains the reconciled forecasts.

4. Evaluation

The HierarchicalForecast package includes an evaluate function to evaluate the different hierarchies and also is capable of compute scaled metrics compared to a benchmark model.

RMSE

The following table shows the performance measured using RMSE across levels for each reconciliation method.

MASE

The following table shows the performance measured using MASE across levels for each reconciliation method.

Comparison with fable

Observe that we can recover the results reported by the Forecasting: Principles and Practice. The original results were calculated using the R package fable.

References