Skip to main content
A minimal example of using Hierarchical Forecast with NeuralForecast
This notebook offers a step by step guide to create a hierarchical forecasting pipeline. In the pipeline we will use NeuralForecast and HINT class, to create fit, predict and reconcile forecasts. We will use the TourismL dataset that summarizes large Australian national visitor survey. Outline
1. Installing packages
2. Load hierarchical dataset
3. Fit and Predict HINT
4. Benchmark methods
5. Forecast Evaluation
You can run these experiments using GPU with Google Colab. Open In Colab

1. Installing packages

2. Load hierarchical dataset

This detailed Australian Tourism Dataset comes from the National Visitor Survey, managed by the Tourism Research Australia, it is composed of 555 monthly series from 1998 to 2016, it is organized geographically, and purpose of travel. The natural geographical hierarchy comprises seven states, divided further in 27 zones and 76 regions. The purpose of travel categories are holiday, visiting friends and relatives (VFR), business and other. The MinT (Wickramasuriya et al., 2019), among other hierarchical forecasting studies has used the dataset it in the past. The dataset can be accessed in the MinT reconciliation webpage, although other sources are available.
Geographical DivisionNumber of series per divisionNumber of series per purposeTotal
Australia145
States72835
Zones27108135
Regions76304380
Total111444555
Mathematically a hierarchical multivariate time series can be denoted by the vector y[a,b],t\mathbf{y}_{[a,b],t} defined by the following aggregation constraint: y[a,b],t=S[a,b][b]y[b],t[y[a],ty[b],t]=[A[a][b]I[b][b]]y[b],t\mathbf{y}_{[a,b],t} = \mathbf{S}_{[a,b][b]} \mathbf{y}_{[b],t} \quad \Leftrightarrow \quad \begin{bmatrix}\mathbf{y}_{[a],t} \\ %\hline \mathbf{y}_{[b],t}\end{bmatrix} = \begin{bmatrix} \mathbf{A}_{[a][b]}\\ %\hline \mathbf{I}_{[b][b]} \end{bmatrix} \mathbf{y}_{[b],t} where y[a],t\mathbf{y}_{[a],t} are the aggregate series, y[b],t\mathbf{y}_{[b],t} are the bottom level series and S[a,b][b]\mathbf{S}_{[a,b][b]} are the hierarchical aggregation constraints.

3. Fit and Predict HINT

The Hierarchical Forecast Network (HINT) combines into an easy to use model three components:
1. SoTA neural forecast model.
2. An efficient and flexible multivariate probability distribution.
3. Builtin reconciliation capabilities.

4. Benchmark methods

We compare against AutoARIMA, a well-established traditional forecasting method from the StatsForecast package, for which we reconcile the forecasts using HierarchicalForecast.
We define the model, and create the forecasts.
Next, we reconcile the forecasts using BottomUp and MinTrace reconciliation techniques:

5. Forecast Evaluation

To evaluate the coherent probabilistic predictions we use the scaled Continuous Ranked Probability Score (sCRPS), defined as follows: CRPS(F^[a,b],τ,y[a,b],τ)=2Na+Nbi01QL(F^i,τ,yi,τ)qdq\mathrm{CRPS}(\hat{F}_{[a,b],\tau},\mathbf{y}_{[a,b],\tau}) = \frac{2}{N_{a}+N_{b}} \sum_{i} \int^{1}_{0} \mathrm{QL}(\hat{F}_{i,\tau}, y_{i,\tau})_{q} dq sCRPS(F^[a,b],τ,y[a,b],τ)=CRPS(F^[a,b],τ,y[a,b],τ)iyi,τ\mathrm{sCRPS}(\hat{F}_{[a,b\,],\tau},\mathbf{y}_{[a,b\,],\tau}) = \frac{\mathrm{CRPS}(\hat{F}_{[a,b\,],\tau},\mathbf{y}_{[a,b\,],\tau})}{\sum_{i} | y_{i,\tau} |} As you can see the HINT model (using NHITS as base model) efficiently achieves state of the art accuracy under minimal tuning.
levelmetricNHITSAutoARIMA
0Countryscaled_crps0.0444310.131136
1Country/Statescaled_crps0.0634110.147516
2Country/State/Zonescaled_crps0.1060600.174071
3Country/State/Zone/Regionscaled_crps0.1519880.205654
4Country/Purposescaled_crps0.0758210.133664
5Country/State/Purposescaled_crps0.1146740.181850
6Country/State/Zone/Purposescaled_crps0.1804910.244324
7Country/State/Zone/Region/Purposescaled_crps0.2454660.310656
8Overallscaled_crps0.1227930.191109

References