Skip to main content

No project description provided

Project description

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!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hierarchical_prophet-0.0.1.tar.gz (26.7 kB view details)

Uploaded Source

Built Distribution

hierarchical_prophet-0.0.1-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

Details for the file hierarchical_prophet-0.0.1.tar.gz.

File metadata

  • Download URL: hierarchical_prophet-0.0.1.tar.gz
  • Upload date:
  • Size: 26.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.8 Darwin/23.2.0

File hashes

Hashes for hierarchical_prophet-0.0.1.tar.gz
Algorithm Hash digest
SHA256 fe32c81e8863d4659912a72ea5da7b29356ca84a0fcccbd4dd8d06f63e47041e
MD5 e8fdeaefba6776cd9c96847edff3df00
BLAKE2b-256 0fff17753e21e3e533501780b2850f132e9330cfd1b3574c9f8b81c1514808db

See more details on using hashes here.

File details

Details for the file hierarchical_prophet-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for hierarchical_prophet-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dbc6de9cf91fae46718c9e3dc982c8445821afdaed49531a232430fbc199584d
MD5 e6704d4ad1c0519d67e06ae6e2dcfb5b
BLAKE2b-256 1b21cda8a7ff41d74bb1c239919ba6369427b3f8899319383193cb4c6e5eed43

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page