Skip to main content

Hierarchical Prophet

PyPI version Downloads Downloads Downloads

This library was created to make a numpyro-based Prophet model for timeseries forecasting. In addition, it also provides an extension that allows for hierarchical forecasting simultaneously, with potentially shared coefficients between timeseries. All implementations (hierarchical and univariate) are based on sktime interface.

The hierarchical one creates a Prophet-like model for each bottom series, but uses a multivariate normal likelihood based on the hierarchy structure to also consider information of middle-top levels.

Hierarchical Model

Let $Y_{bottom} \in \mathcal{R}^{b}$ be the random vector of bottom series which follow a normal distribution $\mathcal{N}(y_{bottom}, \Sigma)$, where $\Sigma \in \mathcal{R}^{b \times b}$ is the covariance matrix of the bottom series which we assume is diagonal. In addition, let $ S \in \mathcal{R}^{m \times b}$ be the matrix that define the hierarchical structure of the series, where $m \geq b$ is the total number of series . Then, the random variable $Y$ which define the value of all series is defined as:

$$ Y = SY_{bottom} $$

Its distribution is given by:

$$ Y \sim \mathcal{N}(SY_{bottom}, S\Sigma S^T) $$

A custom distribution was implemented so that samples are drawn according to that multivariate distribution - in a bottom-up fashion -, and the likelihood applied to all levels at once.

Installation

Remarks

Differences between this Prophet and the original one

The main differences with the original Prophet model are:

  1. The logistic version of the trend. In the original paper, the logistic growth is:

    $$ trend = \frac{C}{1 + \exp(-k(t - m))} $$

    where $C$ is the capacity, $k$ is the growth rate and $m$ is the inflection point. In this implementation, we implement a similar and equivalent model, but with a different parameterization:

    $$ trend = \frac{C}{1 + \exp(-(kt + m))} $$

    which are equivalent. The priors for those parameters $k$ and $m$ are chosen in a data driven way, so that they match the maximum and minimum value of the series.

  2. The capacity is also modelled as a random variable, and it's assumed constant.

  3. One can set different prior distributions for the parameters of the model. The parameters also may be different for different groups of variables, which allows to force positive coefficients for some groups and not for others (with HalfNormal prior, for example).

  4. The exogenous variable inputs are not scaled. They should be scaled prior to the model fitting, with sktime transfomers for example.

Differences between this Hierarchical Prophet and the original one

  1. All the above
  2. Changepoint interval is used instead of changepoint number. Motivation: as the timeseries evolve, a given changepoint number may have different meanings. For example, a changepoint number of 10 may be too much for a series with 100 observations, but too little for a series with 1000 observations. The changepoint interval may avoid this problem.
  3. The fourier terms for seasonality must be passed as exogenous variables. For the moment, the following features are not implemented:
  • Maximum a posteriori estimation (mcmc_samples=0). Only MCMC with NUTS is implemented.
  • There's no method/function for extracting the timeseries components (trend, seasonality, etc) from the model directly. Although 100% possible, it's not implemented as a function or method yet. Contributions are welcome!

Metadata

Release files for hierarchical-prophet 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hierarchical-prophet 0.0.1
File Size Uploaded Provenance
hierarchical_prophet-0.0.1.tar.gz 26.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for hierarchical-prophet 0.0.1
File Interpreter ABI Platform
hierarchical_prophet-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 58.1 kB

Release files / hierarchical_prophet-0.0.1.tar.gz

Download URL hierarchical_prophet-0.0.1.tar.gz
Size 26.7 kB
Tags Source
SHA-256 checksum
How to use checksums
fe32c81e8863d4659912a72ea5da7b29356ca84a0fcccbd4dd8d06f63e47041e
BLAKE2b-256 checksum
How to use checksums
0fff17753e21e3e533501780b2850f132e9330cfd1b3574c9f8b81c1514808db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.11.8 Darwin/23.2.0

Release files / hierarchical_prophet-0.0.1-py3-none-any.whl

Download URL hierarchical_prophet-0.0.1-py3-none-any.whl
Size 31.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dbc6de9cf91fae46718c9e3dc982c8445821afdaed49531a232430fbc199584d
BLAKE2b-256 checksum
How to use checksums
1b21cda8a7ff41d74bb1c239919ba6369427b3f8899319383193cb4c6e5eed43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.11.8 Darwin/23.2.0

Security for hierarchical-prophet 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page