Skip to main content

A time-series forecasting package with an intuitive API capable of modeling short time series with prior knowledge derived from a similar long time series.

Project description

vangja

A time-series forecasting package based on Facebook Prophet with an intuitive API capable of modeling short time-series with prior knowledge derived from a similar long time-series.

This package has been inspired by:

Installation

You need to create a conda PyMC environment before installing vangja. The recommended way of installing PyMC is by running:

conda create -c conda-forge -n pymc_env python=3.12 "pymc>=5.20.1"

Install vangja with pip:

pip install vangja

Usage

The data used for fitting the models is expected to be in the same format as the data used for fitting the Facebook Prophet model i.e. it should be a pandas dataframe, where the timestamp is stored in column ds and the value is stored in column y.

The API is heavily inspired by TimeSeers. A simple model consisting of a linear trend, a yearly seasonality and a weekly seasonality can be fitted like this:

from vangja import LinearTrend, FourierSeasonality

model = LinearTrend() + FourierSeasonality(365.25, 10) + FourierSeasonality(7, 10)
model.fit(data)
model.predict(365)

Multiplicative compositions

There are two types of multiplicative compositions that vangja supports. The first one supports creating models from components $g(t)$ and $s(t)$ in the form $y(t)=g(t) * (1 + s(t))$. Using vangja, this can be written by using the __pow__ operator:

model = LinearTrend() ** FourierSeasonality(365.25, 10)

The second multiplicative composition supports creating models from components $g(t)$ and $s(t)$ in the form $y(t)=g(t) * s(t)$. Using vangja, this can be written by using the __mul__ operator:

model = LinearTrend() * FourierSeasonality(365.25, 10)

Components

Currently, vangja supports the following components:

  • LinearTrend(n_changepoints=25, changepoint_range=0.8, slope_mean=0, slope_sd=5, intercept_mean=0, intercept_sd=5, delta_mean=0, delta_sd=0.05, allow_tune=False)
  • FourierSeasonality(period, series_order, beta_mean=0, beta_sd=10, allow_tune=False,tune_method="simple")
  • UniformConstant(lower, upper, allow_tune=False)
  • BetaConstant(lower, upper, alpha=0.5, beta=0.5, allow_tune=False)
  • NormalConstant(mu=0, sd=1, allow_tune=False)

Model tuning

If you are given a long time-series and a "similar" short time-series, you can fit a model on the long time-series and then tune it on the short time-series. This is especially useful if you want to model a long seasonality on the short time-series, but you do not have enough data to do it (e.g. you have 3 months of data and want to model the yearly seasonality). In vangja, this can be written like this:

model = LinearTrend() + FourierSeasonality(365.25, 10, allow_tune=True)
model.fit(long_time_series)
model.tune(short_time_series)
model.predict(365)

Contributing

Pull requests and suggestions are always welcome. Please open an issue on the issue list before submitting in order to avoid doing unnecessary work.

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

vangja-0.1.2.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vangja-0.1.2-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file vangja-0.1.2.tar.gz.

File metadata

  • Download URL: vangja-0.1.2.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for vangja-0.1.2.tar.gz
Algorithm Hash digest
SHA256 dd8eea6e9521080258443b11a515de5439ac1b45630757ad48218098021c02b9
MD5 0b08f5345f5c6c80705344f0eb506e8b
BLAKE2b-256 e1b4a6d5c9e67856809d1c8c7ce76a23fe0a8ac778edaaff22db7d6a60e255a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for vangja-0.1.2.tar.gz:

Publisher: python-publish.yml on jovan-krajevski/vangja

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vangja-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: vangja-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for vangja-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4c7bbaf5ae99e75615065beb0d70820a52c3f4cb02f8d463736b27909febebec
MD5 4cde33d70b02c651677030675bd30ca0
BLAKE2b-256 7bc9088d62313ccb3744e56a0b165d2c4e6a76b74dc6cfb0ce5e60ce45e3652d

See more details on using hashes here.

Provenance

The following attestation bundles were made for vangja-0.1.2-py3-none-any.whl:

Publisher: python-publish.yml on jovan-krajevski/vangja

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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