Skip to main content

HierarchicalForecast contains pure Python implementations of hierarchical reconciliation methods as well as a core.HierarchicalReconciliation wrapper class that enables easy interaction with these methods through pandas DataFrames containing the hierarchical time series and the base predictions. The core.HierarchicalReconciliation reconciliation class operates with the hierarchical time series pd.DataFrame Y_df, the base predictions pd.DataFrame Y_hat_df, the aggregation constraints matrix S_df. For more information on the creation of aggregation constraints matrix see the utils aggregation method

HierarchicalReconciliation

Hierarchical Reconciliation Class. The core.HierarchicalReconciliation class allows you to efficiently fit multiple HierarchicaForecast methods for a collection of time series and base predictions stored in pandas DataFrames. The Y_df dataframe identifies series and datestamps with the unique_id and ds columns while the y column denotes the target time series variable. The Y_h dataframe stores the base predictions, example (AutoARIMA, ETS, etc.). Parameters:

HierarchicalReconciliation.reconcile

Hierarchical Reconciliation Method. The reconcile method is analogous to SKLearn fit_predict method, it applies different reconciliation techniques instantiated in the reconcilers list. Most reconciliation methods can be described by the following convenient linear algebra notation: y~[a,b],tau=S[a,b][b]P[b][a,b]y^[a,b],tau\tilde{\mathbf{y}}_{[a,b],\\tau} = \mathbf{S}_{[a,b][b]} \mathbf{P}_{[b][a,b]} \hat{\mathbf{y}}_{[a,b],\\tau} where a,ba, b represent the aggregate and bottom levels, S[a,b][b]\mathbf{S}_{[a,b][b]} contains the hierarchical aggregation constraints, and P[b][a,b]\mathbf{P}_{[b][a,b]} varies across reconciliation methods. The reconciled predictions are y~[a,b],τ\tilde{\mathbf{y}}_{[a,b],\tau} and the base predictions y^[a,b],τ\hat{\mathbf{y}}_{[a,b],\tau} Parameters: Returns:

HierarchicalReconciliation.bootstrap_reconcile

Bootstraped Hierarchical Reconciliation Method. Applies N times, based on different random seeds, the reconcile method for the different reconciliation techniques instantiated in the reconcilers list. Parameters: Returns:

Example