hierarchicalforecast.methods
HReconciler
fit
fit_predict
predict
S
(np.ndarray): Summing matrix of size (base
, bottom
).y_hat
(np.ndarray): Forecast values of size (base
, horizon
).level
(Optional[list[int]], optional): float list 0-100, confidence levels for prediction intervals. Default is None.dict
: y_tilde: Reconciliated predictions.sample
intervals_method
selected during the reconcilerβs instantiation. Currently available: normality
, bootstrap
, permbu
.
Args:
num_samples
(int): number of samples generated from coherent distribution.np.ndarray
: samples: Coherent samples of size (num_series
, horizon
, num_samples
).BottomUp
fit
S
(np.ndarray): Summing matrix of size (base
, bottom
).y_hat
(np.ndarray): Forecast values of size (base
, horizon
).idx_bottom
(np.ndarray): Indices corresponding to the bottom level of S
, size (bottom
).y_insample
(Optional[np.ndarray], optional): In-sample values of size (base
, horizon
). Default is None.y_hat_insample
(Optional[np.ndarray], optional): In-sample forecast values of size (base
, horizon
). Default is None.sigmah
(Optional[np.ndarray], optional): Estimated standard deviation of the conditional marginal distribution. Default is None.intervals_method
(Optional[str], optional): Sampler for prediction intervals, one of normality
, bootstrap
, permbu
. Default is None.num_samples
(Optional[int], optional): Number of samples for probabilistic coherent distribution. Default is None.seed
(Optional[int], optional): Seed for reproducibility. Default is None.tags
(Optional[dict[str, np.ndarray]], optional): Tags for hierarchical structure. Default is None.BottomUp
: object, fitted reconciler.fit_predict
S
(np.ndarray): Summing matrix of size (base
, bottom
).y_hat
(np.ndarray): Forecast values of size (base
, horizon
).idx_bottom
(np.ndarray): Indices corresponding to the bottom level of S
, size (bottom
).y_insample
(Optional[np.ndarray], optional): In-sample values of size (base
, insample_size
). Default is None.y_hat_insample
(Optional[np.ndarray], optional): In-sample forecast values of size (base
, insample_size
). Default is None.sigmah
(Optional[np.ndarray], optional): Estimated standard deviation of the conditional marginal distribution. Default is None.level
(Optional[list[int]], optional): float list 0-100, confidence levels for prediction intervals. Default is None.intervals_method
(Optional[str], optional): Sampler for prediction intervals, one of normality
, bootstrap
, permbu
. Default is None.num_samples
(Optional[int], optional): Number of samples for probabilistic coherent distribution. Default is None.seed
(Optional[int], optional): Seed for reproducibility. Default is None.tags
(Optional[dict[str, np.ndarray]], optional): Tags for hierarchical structure. Default is None.dict
: y_tilde: Reconciliated y_hat using the Bottom Up approach.predict
S
(np.ndarray): Summing matrix of size (base
, bottom
).y_hat
(np.ndarray): Forecast values of size (base
, horizon
).level
(Optional[list[int]], optional): float list 0-100, confidence levels for prediction intervals. Default is None.dict
: y_tilde: Reconciliated predictions.sample
intervals_method
selected during the reconcilerβs instantiation. Currently available: normality
, bootstrap
, permbu
.
Args:
num_samples
(int): number of samples generated from coherent distribution.np.ndarray
: samples: Coherent samples of size (num_series
, horizon
, num_samples
).BottomUpSparse
fit
S
(np.ndarray): Summing matrix of size (base
, bottom
).y_hat
(np.ndarray): Forecast values of size (base
, horizon
).idx_bottom
(np.ndarray): Indices corresponding to the bottom level of S
, size (bottom
).y_insample
(Optional[np.ndarray], optional): In-sample values of size (base
, horizon
). Default is None.y_hat_insample
(Optional[np.ndarray], optional): In-sample forecast values of size (base
, horizon
). Default is None.sigmah
(Optional[np.ndarray], optional): Estimated standard deviation of the conditional marginal distribution. Default is None.intervals_method
(Optional[str], optional): Sampler for prediction intervals, one of normality
, bootstrap
, permbu
. Default is None.num_samples
(Optional[int], optional): Number of samples for probabilistic coherent distribution. Default is None.seed
(Optional[int], optional): Seed for reproducibility. Default is None.tags
(Optional[dict[str, np.ndarray]], optional): Tags for hierarchical structure. Default is None.BottomUp
: object, fitted reconciler.fit_predict
S
(np.ndarray): Summing matrix of size (base
, bottom
).y_hat
(np.ndarray): Forecast values of size (base
, horizon
).idx_bottom
(np.ndarray): Indices corresponding to the bottom level of S
, size (bottom
).y_insample
(Optional[np.ndarray], optional): In-sample values of size (base
, insample_size
). Default is None.y_hat_insample
(Optional[np.ndarray], optional): In-sample forecast values of size (base
, insample_size
). Default is None.sigmah
(Optional[np.ndarray], optional): Estimated standard deviation of the conditional marginal distribution. Default is None.level
(Optional[list[int]], optional): float list 0-100, confidence levels for prediction intervals. Default is None.intervals_method
(Optional[str], optional): Sampler for prediction intervals, one of normality
, bootstrap
, permbu
. Default is None.num_samples
(Optional[int], optional): Number of samples for probabilistic coherent distribution. Default is None.seed
(Optional[int], optional): Seed for reproducibility. Default is None.tags
(Optional[dict[str, np.ndarray]], optional): Tags for hierarchical structure. Default is None.dict
: y_tilde: Reconciliated y_hat using the Bottom Up approach.predict
S
(np.ndarray): Summing matrix of size (base
, bottom
).y_hat
(np.ndarray): Forecast values of size (base
, horizon
).level
(Optional[list[int]], optional): float list 0-100, confidence levels for prediction intervals. Default is None.dict
: y_tilde: Reconciliated predictions.sample
intervals_method
selected during the reconcilerβs instantiation. Currently available: normality
, bootstrap
, permbu
.
Args:
num_samples
(int): number of samples generated from coherent distribution.np.ndarray
: samples: Coherent samples of size (num_series
, horizon
, num_samples
).TopDown
method
: One of forecast_proportions
, average_proportions
and proportion_averages
.__init__
fit
S
: Summing matrix of size (base
, bottom
).y_hat
: Forecast values of size (base
, horizon
).y_insample
: Insample values of size (base
, insample_size
). Optional for forecast_proportions
method.y_hat_insample
: Insample forecast values of size (base
, insample_size
). Optional for forecast_proportions
method.sigmah
: Estimated standard deviation of the conditional marginal distribution.interval_method
: Sampler for prediction intervals, one of normality
, bootstrap
, permbu
.num_samples
: Number of samples for probabilistic coherent distribution.seed
: Seed for reproducibility.tags
: Each key is a level and each value its S
indices.idx_bottom
: Indices corresponding to the bottom level of S
, size (bottom
).self
: object, fitted reconciler.fit_predict
S
: Summing matrix of size (base
, bottom
).y_hat
: Forecast values of size (base
, horizon
).tags
: Each key is a level and each value its S
indices.idx_bottom
: Indices corresponding to the bottom level of S
, size (bottom
).y_insample
: Insample values of size (base
, insample_size
). Optional for forecast_proportions
method.y_hat_insample
: Insample forecast values of size (base
, insample_size
). Optional for forecast_proportions
method.sigmah
: Estimated standard deviation of the conditional marginal distribution.level
: float list 0-100, confidence levels for prediction intervals.intervals_method
: Sampler for prediction intervals, one of normality
, bootstrap
, permbu
.num_samples
: Number of samples for probabilistic coherent distribution.seed
: Seed for reproducibility.y_tilde
: Reconciliated y_hat using the Top Down approach.predict
S
(np.ndarray): Summing matrix of size (base
, bottom
).y_hat
(np.ndarray): Forecast values of size (base
, horizon
).level
(Optional[list[int]], optional): float list 0-100, confidence levels for prediction intervals. Default is None.dict
: y_tilde: Reconciliated predictions.sample
intervals_method
selected during the reconcilerβs instantiation. Currently available: normality
, bootstrap
, permbu
.
Args:
num_samples
(int): number of samples generated from coherent distribution.np.ndarray
: samples: Coherent samples of size (num_series
, horizon
, num_samples
).TopDownSparse
__init__
fit
S
: Summing matrix of size (base
, bottom
).y_hat
: Forecast values of size (base
, horizon
).y_insample
: Insample values of size (base
, insample_size
). Optional for forecast_proportions
method.y_hat_insample
: Insample forecast values of size (base
, insample_size
). Optional for forecast_proportions
method.sigmah
: Estimated standard deviation of the conditional marginal distribution.interval_method
: Sampler for prediction intervals, one of normality
, bootstrap
, permbu
.num_samples
: Number of samples for probabilistic coherent distribution.seed
: Seed for reproducibility.tags
: Each key is a level and each value its S
indices.idx_bottom
: Indices corresponding to the bottom level of S
, size (bottom
).self
: object, fitted reconciler.fit_predict
predict
S
(np.ndarray): Summing matrix of size (base
, bottom
).y_hat
(np.ndarray): Forecast values of size (base
, horizon
).level
(Optional[list[int]], optional): float list 0-100, confidence levels for prediction intervals. Default is None.dict
: y_tilde: Reconciliated predictions.sample
intervals_method
selected during the reconcilerβs instantiation. Currently available: normality
, bootstrap
, permbu
.
Args:
num_samples
(int): number of samples generated from coherent distribution.np.ndarray
: samples: Coherent samples of size (num_series
, horizon
, num_samples
).MiddleOut
middle_level
: Middle level.top_down_method
: One of forecast_proportions
, average_proportions
and proportion_averages
.__init__
fit
fit_predict
S
: Summing matrix of size (base
, bottom
).y_hat
: Forecast values of size (base
, horizon
).tags
: Each key is a level and each value its S
indices.y_insample
: Insample values of size (base
, insample_size
). Only used for forecast_proportions
y_hat_insample
: In-sample forecast values of size (base
, insample_size
).sigmah
: Estimated standard deviation of the conditional marginal distribution.level
: float list 0-100, confidence levels for prediction intervals.intervals_method
: Sampler for prediction intervals, one of normality
, bootstrap
, permbu
.num_samples
: Number of samples for probabilistic coherent distribution.seed
: Seed for reproducibility.y_tilde
: Reconciliated y_hat using the Middle Out approach.predict
sample
intervals_method
selected during the reconcilerβs instantiation. Currently available: normality
, bootstrap
, permbu
.
Args:
num_samples
(int): number of samples generated from coherent distribution.np.ndarray
: samples: Coherent samples of size (num_series
, horizon
, num_samples
).MiddleOutSparse
__init__
fit
fit_predict
predict
sample
intervals_method
selected during the reconcilerβs instantiation. Currently available: normality
, bootstrap
, permbu
.
Args:
num_samples
(int): number of samples generated from coherent distribution.np.ndarray
: samples: Coherent samples of size (num_series
, horizon
, num_samples
).MinTrace
method
: str, one of ols
, wls_struct
, wls_var
, mint_shrink
, mint_cov
.nonnegative
: bool, reconciled forecasts should be nonnegative?mint_shr_ridge
: float=2e-8, ridge numeric protection to MinTrace-shr covariance estimator.num_threads
: int=1, number of threads to use for solving the optimization problems (when nonnegative=True).__init__
fit
S
: Summing matrix of size (base
, bottom
).y_hat
: Forecast values of size (base
, horizon
).y_insample
: Insample values of size (base
, insample_size
). Only used with βwls_varβ, βmint_covβ, βmint_shrinkβ.y_hat_insample
: Insample forecast values of size (base
, insample_size
). Only used with βwls_varβ, βmint_covβ, βmint_shrinkβsigmah
: Estimated standard deviation of the conditional marginal distribution.intervals_method
: Sampler for prediction intervals, one of normality
, bootstrap
, permbu
.num_samples
: Number of samples for probabilistic coherent distribution.seed
: Seed for reproducibility.tags
: Each key is a level and each value its S
indices.idx_bottom
: Indices corresponding to the bottom level of S
, size (bottom
).self
: object, fitted reconciler.fit_predict
S
: Summing matrix of size (base
, bottom
).y_hat
: Forecast values of size (base
, horizon
).idx_bottom
: Indices corresponding to the bottom level of S
, size (bottom
).y_insample
: Insample values of size (base
, insample_size
). Only used by wls_var
, mint_cov
, mint_shrink
y_hat_insample
: Insample fitted values of size (base
, insample_size
). Only used by wls_var
, mint_cov
, mint_shrink
sigmah
: Estimated standard deviation of the conditional marginal distribution.level
: float list 0-100, confidence levels for prediction intervals.intervals_method
: Sampler for prediction intervals, one of normality
, bootstrap
, permbu
.num_samples
: Number of samples for probabilistic coherent distribution.seed
: Seed for reproducibility.tags
: Each key is a level and each value its S
indices.y_tilde
: Reconciliated y_hat using the MinTrace approach.predict
S
(np.ndarray): Summing matrix of size (base
, bottom
).y_hat
(np.ndarray): Forecast values of size (base
, horizon
).level
(Optional[list[int]], optional): float list 0-100, confidence levels for prediction intervals. Default is None.dict
: y_tilde: Reconciliated predictions.sample
intervals_method
selected during the reconcilerβs instantiation. Currently available: normality
, bootstrap
, permbu
.
Args:
num_samples
(int): number of samples generated from coherent distribution.np.ndarray
: samples: Coherent samples of size (num_series
, horizon
, num_samples
).MinTraceSparse
method
(str): One of ols
, wls_struct
, or wls_var
.nonnegative
(bool): Return non-negative reconciled forecasts.num_threads
(int): Number of threads to execute non-negative quadratic programming calls.qp
(bool): Implement non-negativity constraint with a quadratic programming approach. Setting this to True generally gives better results, but at the expense of higher cost to compute.__init__
fit
S
: Summing matrix of size (base
, bottom
).y_hat
: Forecast values of size (base
, horizon
).y_insample
: Insample values of size (base
, insample_size
). Only used with βwls_varβ.y_hat_insample
: Insample forecast values of size (base
, insample_size
). Only used with βwls_varβsigmah
: Estimated standard deviation of the conditional marginal distribution.intervals_method
: Sampler for prediction intervals, one of normality
, bootstrap
, permbu
.num_samples
: Number of samples for probabilistic coherent distribution.seed
: Seed for reproducibility.tags
: Each key is a level and each value its S
indices.idx_bottom
: Indices corresponding to the bottom level of S
, size (bottom
).self
: object, fitted reconciler.fit_predict
S
: Summing matrix of size (base
, bottom
).y_hat
: Forecast values of size (base
, horizon
).idx_bottom
: Indices corresponding to the bottom level of S
, size (bottom
).y_insample
: Insample values of size (base
, insample_size
). Only used by wls_var
, mint_cov
, mint_shrink
y_hat_insample
: Insample fitted values of size (base
, insample_size
). Only used by wls_var
, mint_cov
, mint_shrink
sigmah
: Estimated standard deviation of the conditional marginal distribution.level
: float list 0-100, confidence levels for prediction intervals.intervals_method
: Sampler for prediction intervals, one of normality
, bootstrap
, permbu
.num_samples
: Number of samples for probabilistic coherent distribution.seed
: Seed for reproducibility.tags
: Each key is a level and each value its S
indices.y_tilde
: Reconciliated y_hat using the MinTrace approach.predict
S
(np.ndarray): Summing matrix of size (base
, bottom
).y_hat
(np.ndarray): Forecast values of size (base
, horizon
).level
(Optional[list[int]], optional): float list 0-100, confidence levels for prediction intervals. Default is None.dict
: y_tilde: Reconciliated predictions.sample
intervals_method
selected during the reconcilerβs instantiation. Currently available: normality
, bootstrap
, permbu
.
Args:
num_samples
(int): number of samples generated from coherent distribution.np.ndarray
: samples: Coherent samples of size (num_series
, horizon
, num_samples
).OptimalCombination
MinTrace
variants.
Args:
method
: str, allowed optimal combination methods: βolsβ, βwls_structβ.nonnegative
: bool, reconciled forecasts should be nonnegative?__init__
fit
S
: Summing matrix of size (base
, bottom
).y_hat
: Forecast values of size (base
, horizon
).y_insample
: Insample values of size (base
, insample_size
). Only used with βwls_varβ, βmint_covβ, βmint_shrinkβ.y_hat_insample
: Insample forecast values of size (base
, insample_size
). Only used with βwls_varβ, βmint_covβ, βmint_shrinkβsigmah
: Estimated standard deviation of the conditional marginal distribution.intervals_method
: Sampler for prediction intervals, one of normality
, bootstrap
, permbu
.num_samples
: Number of samples for probabilistic coherent distribution.seed
: Seed for reproducibility.tags
: Each key is a level and each value its S
indices.idx_bottom
: Indices corresponding to the bottom level of S
, size (bottom
).self
: object, fitted reconciler.fit_predict
S
: Summing matrix of size (base
, bottom
).y_hat
: Forecast values of size (base
, horizon
).idx_bottom
: Indices corresponding to the bottom level of S
, size (bottom
).y_insample
: Insample values of size (base
, insample_size
). Only used by wls_var
, mint_cov
, mint_shrink
y_hat_insample
: Insample fitted values of size (base
, insample_size
). Only used by wls_var
, mint_cov
, mint_shrink
sigmah
: Estimated standard deviation of the conditional marginal distribution.level
: float list 0-100, confidence levels for prediction intervals.intervals_method
: Sampler for prediction intervals, one of normality
, bootstrap
, permbu
.num_samples
: Number of samples for probabilistic coherent distribution.seed
: Seed for reproducibility.tags
: Each key is a level and each value its S
indices.y_tilde
: Reconciliated y_hat using the MinTrace approach.predict
S
(np.ndarray): Summing matrix of size (base
, bottom
).y_hat
(np.ndarray): Forecast values of size (base
, horizon
).level
(Optional[list[int]], optional): float list 0-100, confidence levels for prediction intervals. Default is None.dict
: y_tilde: Reconciliated predictions.sample
intervals_method
selected during the reconcilerβs instantiation. Currently available: normality
, bootstrap
, permbu
.
Args:
num_samples
(int): number of samples generated from coherent distribution.np.ndarray
: samples: Coherent samples of size (num_series
, horizon
, num_samples
).ERM
method='closed'
) follows the expression:
The alternative Lasso regularized solution (method='reg_bu'
) is useful when the observations of validation data is limited or the exact solution has low numerical stability.
Args:
method
: str, one of closed
, reg
and reg_bu
.lambda_reg
: float, l1 regularizer for reg
and reg_bu
.__init__
fit
S
: Summing matrix of size (base
, bottom
).y_hat
: Forecast values of size (base
, horizon
).y_insample
: Train values of size (base
, insample_size
).y_hat_insample
: Insample train predictions of size (base
, insample_size
).sigmah
: Estimated standard deviation of the conditional marginal distribution.intervals_method
: Sampler for prediction intervals, one of normality
, bootstrap
, permbu
.num_samples
: Number of samples for probabilistic coherent distribution.seed
: Seed for reproducibility.tags
: Each key is a level and each value its S
indices.idx_bottom
: Indices corresponding to the bottom level of S
, size (bottom
).self
: object, fitted reconciler.fit_predict
S
: Summing matrix of size (base
, bottom
).y_hat
: Forecast values of size (base
, horizon
).idx_bottom
: Indices corresponding to the bottom level of S
, size (bottom
).y_insample
: Train values of size (base
, insample_size
).y_hat_insample
: Insample train predictions of size (base
, insample_size
).sigmah
: Estimated standard deviation of the conditional marginal distribution.level
: float list 0-100, confidence levels for prediction intervals.intervals_method
: Sampler for prediction intervals, one of normality
, bootstrap
, permbu
.num_samples
: Number of samples for probabilistic coherent distribution.seed
: Seed for reproducibility.tags
: Each key is a level and each value its S
indices.y_tilde
: Reconciliated y_hat using the ERM approach.predict
S
(np.ndarray): Summing matrix of size (base
, bottom
).y_hat
(np.ndarray): Forecast values of size (base
, horizon
).level
(Optional[list[int]], optional): float list 0-100, confidence levels for prediction intervals. Default is None.dict
: y_tilde: Reconciliated predictions.sample
intervals_method
selected during the reconcilerβs instantiation. Currently available: normality
, bootstrap
, permbu
.
Args:
num_samples
(int): number of samples generated from coherent distribution.np.ndarray
: samples: Coherent samples of size (num_series
, horizon
, num_samples
).