PyFlux: Open-source time series library for Python

May 23, 2020, 9:58 a.m. By: Harshita Kaur

pyflux python

PyFlux is an open source time series analysis and prediction library for Python, the library provides developers a flexible range of inference and modeling array options.

The PyFlux outcome is applicable for forecasting (predicting future) and retrospection (visualizing past). It uses a probabilistic model approach revealing a more complete picture of uncertainty, which is important for time series tasks such as forecasting, maximum likelihood estimation for speed within the same unified API.


The latest version of PyFlux is available on PyPi. It supports Python 2.7 and Python 3.5m major developments are on Python 3.5. Installation of pyflux requires simply calling pip.

pip install pyflux


The process of building models takes fewer steps. The design of PyFlux API is clear and concise. Steps can be given as follows:

  • To create a model instance including main arguments as:

    • A data input (eg. Pandas dataframe)

    • Design parameters (eg. Autoregressive lags for an ARIMA model)

    • A family that specifies the distribution of the modeled time series (eg. Normal Distribution)

  • Prior Information specifying a family for each latent variable in the model that uses ‘adjust_prior’ method. The latent variables can be viewed by printing the ‘latent_variables’ object attached to the model. While using Maximum Likelihood, prior formation can be ignored.

  • Model Fitting (or inference): It uses a fit model, specifying an inference option.

  • Model Evaluation, retrospection and prediction. After confirmation of the fit model the user can look at historical fit, criticize with posterior predictive checks, predict out of samples, and perform other tasks.


PyFlux binds together a vast array of time series models. It includes

  • Score-driven models

  • Variational state space models

  • Flexible choice of inference options that also includes black box variational inference

  • Sports modelling

  • It also includes score driven (GAS) models which are new flexible alternatives to traditional time series models.

GitHub Ref: PyFlux