Sai krishna Sirikonda
05/16/2025, 12:08 PMMax (Nixtla)
05/24/2025, 3:21 AMHierarchicalForecast
library is primarily designed for *forecast reconciliation*—ensuring coherence across different levels of a hierarchy—rather than generating forecasts itself.
To incorporate exogenous variables in hierarchical forecasting, here’s a step-by-step guide:
Step-by-Step Guide
1. Prepare Your Data using `HierarchicalForecast`:
hierarchy_levels = [['top_level'],
['top_level', 'middle_level'],
['top_level', 'middle_level', 'bottom_level']]
Y_hier_df, S_df, tags = aggregate(df=bottom_df, spec=hierarchy_levels)
• Y_hier_df
: DataFrame with your time series at all hierarchical levels.
• S_df
: Structural matrix encoding the aggregation constraints.
• tags
: Dictionary identifying the hierarchy levels of each series.
2. Generate Base Forecasts:
Use any model that supports exogenous variables. Options include:
• StatsForecast: e.g., AutoARIMA
• MLForecast: e.g., LightGBM
• NeuralForecast: e.g., NBEATSx
Make sure to include exogenous features (X_df
) aligned with your target series.
3. Reconcile Forecasts:
Use a reconciliation method from HierarchicalForecast
, such as:
• bottom_up
• top_down
• min_trace
This ensures that forecasts across all levels of the hierarchy are coherent.
Helpful Resources
• HierarchicalForecast Tutorial
• https://nixtlaverse.nixtla.io/hierarchicalforecast/examples/mlframeworksexample.html
• Using Exogenous Variables
â—¦ StatsForecast: https://nixtlaverse.nixtla.io/statsforecast/docs/how-to-guides/exogenous.html
â—¦ MLForecast: https://nixtlaverse.nixtla.io/mlforecast/docs/how-to-guides/exogenous_features.html
â—¦ NeuralForecast: https://nixtlaverse.nixtla.io/neuralforecast/docs/capabilities/exogenous_variables.htmlMax (Nixtla)
05/24/2025, 3:35 AMSai krishna Sirikonda
05/26/2025, 10:42 AM