Forecast example at M5

Welcome to bayesreconpy’s documentation!#

Codecov coverage badge License: LGPL (\>= 3) PyPI Python 3.12+ Total downloads

Bayesian Reconciliation for Hierarchical and Constrained Forecasting#

Forecast reconciliation ensures that probabilistic forecasts across hierarchical, grouped, or constrained time series remain coherent. In this context, coherence means that forecasts at disaggregated levels, such as local components, are consistent with forecasts at aggregated levels, such as system totals. Forecast reconciliation is a post-processing technique applied to independently generated base forecasts that may not satisfy the relevant hierarchical or structural constraints.

While several methods exist for point forecast reconciliation, BayesReconPy focuses on probabilistic reconciliation for different types of hierarchical and grouped time series in Python. Many existing tools for forecast reconciliation are limited to Gaussian or continuous inputs, lack support for discrete or mixed-type forecasts, or are available only in R. BayesReconPy supports the reconciliation of discrete and non-Gaussian forecast distributions using Bayesian forecast reconciliation via conditioning methods. These methods are relevant in several application domains, including energy systems, demand forecasting, and risk analysis.

Installation#

The Python package is available on PyPI and can be installed with:

pip install bayesreconpy

Documentation#

The documentation of the reconciliation functions is available at:

BayesReconPy documentation

Citation#

Please cite the following JOSS paper when using this package in your research:

Biswas et al. (2025). BayesReconPy: A Python package for forecast reconciliation. Journal of Open Source Software, 10(111), 8336. https://doi.org/10.21105/joss.08336

The code for linear forecast reconciliation is an implementation of the original R package. A comparison of the results obtained from the R and Python versions can be found in the old README file of this package.

Extension to Nonlinear Reconciliation#

From version 0.5.0, BayesReconPy also includes algorithms for reconciling time series with nonlinear constraints. Bayesian reconciliation methods based on conditioning are available in the new nonlinear module of the package.

The original functions for linear forecast reconciliation can also be called from the new linear module of the package.

An Important Note on Projection-Based Approaches#

Although the main goal of this package is to perform probabilistic forecast reconciliation using Bayesian approaches, projection-based approaches are also included for completeness. This allows users to compare different reconciliation methods across both linear and nonlinear settings.

The github page for this python implementation can be found here

Indices and tables#