Abstract
Large collections of time series data are commonly organized into structures with different levels of aggregation; examples include product and geographical groupings. It is often important to ensure that the forecasts are coherent so that the predicted values at disaggregate levels add up to the aggregate forecast. The growing interest of the Machine Learning community in hierarchical forecasting systems indicates that we are in a propitious moment to ensure that scientific endeavors are grounded on sound baselines. For this reason, we put forward the HierarchicalForecast library, which contains preprocessed publicly available datasets, evaluation metrics, and a compiled set of statistical baseline models. Our Python-based reference framework aims to bridge the gap between statistical and econometric modeling, and Machine Learning forecasting research. Code and documentation are available in https://github.com/Nixtla/hierarchicalforecast.
Introduction
In many real-world applications, time series data is organized into hierarchical structures, such as retail sales aggregated by region, store, and product category. A critical challenge in forecasting these structures is maintaining "coherence"—ensuring that forecasts at lower levels of the hierarchy sum up to the forecasts at higher levels. Historically, the most robust tools for hierarchical reconciliation were confined to the R ecosystem, creating a significant barrier for Python-based machine learning researchers. Furthermore, the computational overhead of traditional statistical baselines often made them impractical for large-scale Python applications.
The HierarchicalForecast Framework
HierarchicalForecast is an open-source Python library designed to provide a unified, high-performance framework for hierarchical time series forecasting. It addresses the "language gap" by offering native Python implementations of state-of-the-art reconciliation methods. By leveraging Numba, a just-in-time compiler, the library achieves C-level execution speeds, allowing statistical models like AutoARIMA and ETS to serve as viable, high-speed benchmarks.
As shown in the comparison above, HierarchicalForecast provides the most comprehensive suite of reconciliation methods in the Python ecosystem, particularly in the realm of probabilistic forecasting.
Methodology
The library utilizes a two-step reconciliation workflow:
- Base Forecasting: Independent forecasts are generated for every series in the hierarchy using the
statsforecastpackage. - Reconciliation: A reconciliation method is applied to adjust these base forecasts to satisfy the hierarchical constraints.
The framework supports a wide array of methods, including:
- Point Forecasting: Bottom-Up, Top-Down, Middle-Out, MinTrace (Minimum Trace), and ERM (Empirical Risk Minimization).
- Probabilistic Forecasting: A unique feature of this library is the inclusion of methods like PERMBU, NORMALITY, and BOOTSTRAP, which enable the generation of coherent uncertainty intervals.
Benchmarking and Results
To facilitate rigorous research, the library includes built-in access to five standard datasets: Australian Labour, SF Traffic, Tourism-S, Tourism-L, and Wiki2. These datasets are preprocessed and ready for benchmarking. The performance of the library's probabilistic reconciliation methods was evaluated using the scaled Continuous Ranked Probability Score (sCRPS).
The results demonstrate that the library's implementations are both accurate and consistent with established literature, successfully handling complex structures like the Wiki2 dataset.
Conclusion
HierarchicalForecast bridges the gap between econometrics and machine learning by providing a fast, reliable, and comprehensive Python framework. By making advanced reconciliation methods and standardized datasets easily accessible, it sets a new baseline for hierarchical forecasting research and application. Future work will focus on expanding method combinations and supporting more complex group structures.
Summary updated