What is Hierarchical Forecasting?
Hierarchical forecasting involves generating forecasts for multiple time series that share a hierarchical structure (e.g., product demand by category, department, or region). The goal is to ensure that forecasts are coherent across each level of the hierarchy. Hierarchical forecasting can be particularly important when you need to generate forecasts at different granularities (e.g., country, state, region) and ensure they align with each other and aggregate correctly at higher levels. Using TimeGPT, you can create forecasts for multiple related time series and then apply hierarchical forecasting methods from HierarchicalForecast to reconcile those forecasts across your specified hierarchy.Why use Hierarchical Forecasting?
- Ensures consistency: Forecasts at lower levels add up to higher-level forecasts.
- Improves accuracy: Reconciliation methods often yield more robust predictions.
- Facilitates deeper insights: Understand how smaller segments contribute to overall trends.
Tutorial
Step 1: Install, Import and Initialize
Start by installing the required packages.Step 2: Load and Prepare Data
This tutorial uses the Australian Tourism dataset from Forecasting: Principles and Practices. The dataset contains different levels of hierarchical data, from the entire country of Australia down to individual regions.

Examples of Australia's Tourism Hierarchy and Map
Country | Region | State | Purpose | ds | y |
---|---|---|---|---|---|
Australia | Adelaide | South Australia | Business | 1998-01-01 | 135.077690 |
Australia | Adelaide | South Australia | Business | 1998-04-01 | 109.987316 |
Australia | Adelaide | South Australia | Business | 1998-07-01 | 166.034687 |
Australia | Adelaide | South Australia | Business | 1998-10-01 | 127.160464 |
Australia | Adelaide | South Australia | Business | 1999-01-01 | 137.448533 |
Australia | Adelaide | South Australia | Business | 1999-04-01 | 199.912586 |
Australia | Adelaide | South Australia | Business | 1999-07-01 | 169.355090 |
Australia | Adelaide | South Australia | Business | 1999-10-01 | 134.357937 |
Australia | Adelaide | South Australia | Business | 2000-01-01 | 154.034398 |
Australia | Adelaide | South Australia | Business | 2000-04-01 | 168.776364 |
aggregate
from HierarchicalForecast
to generate the aggregated series:
unique_id | ds | y |
---|---|---|
Australia | 1998-01-01 | 23182.197269 |
Australia | 1998-04-01 | 20323.380067 |
Australia | 1998-07-01 | 19826.640511 |
Australia | 1998-10-01 | 20830.129891 |
Australia | 1999-01-01 | 22087.353380 |
Australia | 1999-04-01 | 21458.373285 |
Australia | 1999-07-01 | 19914.192508 |
Australia | 1999-10-01 | 20027.925640 |
Australia | 2000-01-01 | 22339.294779 |
Australia | 2000-04-01 | 19941.063482 |
Step 3: Hierarchical Forecasting Using TimeGPT
Now we’ll generate base forecasts across all series using TimeGPT and then apply hierarchical reconciliation to ensure the forecasts align across each level.Generate Base Forecasts with TimeGPT
Obtain forecasts with TimeGPT for all series in your training data.Visualize TimeGPT Forecasts
Quickly visualize the forecasts for different hierarchy levels. Here, we look at the entire country, the state of Queensland, the Brisbane region, and holidays in Brisbane:
Apply Hierarchical Reconciliation
We useMinTrace
methods to reconcile forecasts across all levels of the hierarchy.

Step 4: Evaluate Forecast Accuracy
Finally, evaluate your forecast performance using RMSE for different levels of the hierarchy, from total (country) to bottom-level (region/purpose).level | metric | TimeGPT | TimeGPT/MinTrace_method-ols | TimeGPT/MinTrace_method-mint_shrink | |
---|---|---|---|---|---|
0 | Total | rmse | 1433.07 | 1436.07 | 1627.43 |
1 | Purpose | rmse | 482.09 | 475.64 | 507.50 |
2 | State | rmse | 275.85 | 278.39 | 294.28 |
3 | Regions | rmse | 49.40 | 47.91 | 47.99 |
4 | Bottom | rmse | 19.32 | 19.11 | 18.86 |
5 | Overall | rmse | 38.66 | 38.21 | 39.16 |
Conclusion
We made a small improvement in overall RMSE by reconciling the forecasts withMinTrace(ols)
, and made them slightly worse using MinTrace(mint_shrink)
,
indicating that the base forecasts were relatively strong already.
However, we now have coherent forecasts too - so not only did we make a (small)
accuracy improvement, we also got coherency to the hierarchy as a result of our
reconciliation step.