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
. For
more information on the creation of aggregation constraints matrix see
the utils aggregation
method.*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:reconcilers
: A list of instantiated classes of the
reconciliation
methods
module .*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:
where represent the aggregate and bottom levels,
contains the hierarchical aggregation
constraints, and varies across reconciliation
methods. The reconciled predictions are
, and the base predictions
.
Parameters:Y_hat_df
: DataFrame, base forecasts with columns
[βunique_idβ, βdsβ] and models to reconcile.tags
: Each key is a
level and its value contains tags associated to that level.S_df
:
DataFrame with summing matrix of size (base, bottom)
, see aggregate
method.Y_df
: DataFrame, training set of base time series with columns
['unique_id', 'ds', 'y']
.self.reconciles
receives
y_hat_insample
, Y_df
must include them as columns.level
:
positive float list [0,100), confidence levels for prediction
intervals.intervals_method
: str, method used to calculate
prediction intervals, one of normality
, bootstrap
, permbu
.num_samples
: int=-1, if positive return that many probabilistic
coherent samples. seed
: int=0, random seed for numpy generatorβs
replicability.is_balanced
: bool=False, wether Y_df
is balanced,
set it to True to speed things up if Y_df
is balanced.id_col
:
str=βunique_idβ, column that identifies each serie.time_col
:
str=βdsβ, column that identifies each timestep, its values can be
timestamps or integers.target_col
: str=βyβ, column that contains
the target.Y_tilde_df
: DataFrame, with reconciled predictions.*
Type | Default | Details | |
---|---|---|---|
Y_hat_df | Union | ||
tags | dict | ||
S_df | Union | None | |
Y_df | Union | None | |
level | Optional | None | |
intervals_method | str | normality | |
num_samples | int | -1 | |
seed | int | 0 | |
is_balanced | bool | False | |
id_col | str | unique_id | |
time_col | str | ds | |
target_col | str | y | |
id_time_col | str | temporal_id | |
temporal | bool | False | |
S | Union | None | For compatibility with the old API, S_df is now S |
Returns | FrameT |
*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:Y_hat_df
: DataFrame, base forecasts with columns
[βunique_idβ, βdsβ] and models to reconcile.S_df
: DataFrame
with summing matrix of size (base, bottom)
, see aggregate
method.tags
: Each key is a level and its value contains tags associated to
that level.Y_df
: DataFrame, training set of base time series with
columns ['unique_id', 'ds', 'y']
.self.reconciles
receives y_hat_insample
, Y_df
must include them as columns.level
: positive float list [0,100), confidence levels for prediction
intervals.intervals_method
: str, method used to calculate
prediction intervals, one of normality
, bootstrap
, permbu
.num_samples
: int=-1, if positive return that many probabilistic
coherent samples. num_seeds
: int=1, random seed for numpy generatorβs
replicability.id_col
: str=βunique_idβ, column that identifies
each serie.time_col
: str=βdsβ, column that identifies each
timestep, its values can be timestamps or integers.target_col
:
str=βyβ, column that contains the target.Y_bootstrap_df
: DataFrame, with bootstraped
reconciled predictions.*