Skip to main content

Time series forecasting suite using statistical models

Project description

Nixtla   Tweet  Slack

All Contributors

Statistical ⚡️ Forecast

Lightning fast forecasting with statistical and econometric models

CI Python PyPi conda-nixtla License docs Downloads

StatsForecast offers a collection of widely used univariate time series forecasting models, including automatic ARIMA, ETS, CES, and Theta modeling optimized for high performance using numba. It also includes a large battery of benchmarking models.

Installation

You can install StatsForecast with:

pip install statsforecast

or

conda install -c conda-forge statsforecast

Vist our Installation Guide for further instructions.

Quick Start

Minimal Example

from statsforecast import StatsForecast
from statsforecast.models import AutoARIMA
from statsforecast.utils import AirPassengersDF

df = AirPassengersDF
sf = StatsForecast(
    models = [AutoARIMA(season_length = 12)],
    freq = 'M'
)

sf.fit(df)
sf.predict(h=12, level=[95])

Get Started with this quick guide.

Follow this end-to-end walkthrough for best practices.

Why?

Current Python alternatives for statistical models are slow, inaccurate and don't scale well. So we created a library that can be used to forecast in production environments or as benchmarks. StatsForecast includes an extensive battery of models that can efficiently fit millions of time series.

Features

  • Fastest and most accurate implementations of AutoARIMA, AutoETS, AutoCES, MSTL and Theta in Python.
  • Out-of-the-box compatibility with Spark, Dask, and Ray.
  • Probabilistic Forecasting and Confidence Intervals.
  • Support for exogenous Variables and static covariates.
  • Anomaly Detection.
  • Familiar sklearn syntax: .fit and .predict.

Highlights

  • Inclusion of exogenous variables and prediction intervals for ARIMA.
  • 20x faster than pmdarima.
  • 1.5x faster than R.
  • 500x faster than Prophet.
  • 4x faster than statsmodels.
  • Compiled to high performance machine code through numba.
  • 1,000,000 series in 30 min with ray.
  • Replace FB-Prophet in two lines of code and gain speed and accuracy. Check the experiments here.
  • Fit 10 benchmark models on 1,000,000 series in under 5 min.

Missing something? Please open an issue or write us in Slack

Examples and Guides

📚 End to End Walkthrough: Model training, evaluation and selection for multiple time series

🔎 Anomaly Detection: detect anomalies for time series using in-sample prediction intervals.

👩‍🔬 Cross Validation: robust model’s performance evaluation.

❄️ Multiple Seasonalities: how to forecast data with multiple seasonalities using an MSTL.

🔌 Predict Demand Peaks: electricity load forecasting for detecting daily peaks and reducing electric bills.

📈 Intermittent Demand: forecast series with very few non-zero observations.

🌡️ Exogenous Regressors: like weather or prices

Models

Automatic Forecasting

Automatic forecasting tools search for the best parameters and select the best possible model for a group of time series. These tools are useful for large collections of univariate time series.

Model Point Forecast Probabilistic Forecast Insample fitted values Probabilistic fitted values Exogenous features
AutoARIMA
AutoETS
AutoCES
AutoTheta

ARIMA Family

These models exploit the existing autocorrelations in the time series.

Model Point Forecast Probabilistic Forecast Insample fitted values Probabilistic fitted values Exogenous features
ARIMA
AutoRegressive

Theta Family

Fit two theta lines to a deseasonalized time series, using different techniques to obtain and combine the two theta lines to produce the final forecasts.

Model Point Forecast Probabilistic Forecast Insample fitted values Probabilistic fitted values Exogenous features
Theta
OptimizedTheta
DynamicTheta
DynamicOptimizedTheta

Multiple Seasonalities

Suited for signals with more than one clear seasonality. Useful for low-frequency data like electricity and logs.

Model Point Forecast Probabilistic Forecast Insample fitted values Probabilistic fitted values Exogenous features
MSTL If trend forecaster supports

GARCH and ARCH Models

Suited for modeling time series that exhibit non-constant volatility over time. The ARCH model is a particular case of GARCH.

Model Point Forecast Probabilistic Forecast Insample fitted values Probabilistic fitted values Exogenous features
GARCH
ARCH

Baseline Models

Classical models for establishing baseline.

Model Point Forecast Probabilistic Forecast Insample fitted values Probabilistic fitted values Exogenous features
HistoricAverage
Naive
RandomWalkWithDrift
SeasonalNaive
WindowAverage
SeasonalWindowAverage

Exponential Smoothing

Uses a weighted average of all past observations where the weights decrease exponentially into the past. Suitable for data with clear trend and/or seasonality. Use the SimpleExponential family for data with no clear trend or seasonality.

Model Point Forecast Probabilistic Forecast Insample fitted values Probabilistic fitted values Exogenous features
SimpleExponentialSmoothing
SimpleExponentialSmoothingOptimized
SeasonalExponentialSmoothing
SeasonalExponentialSmoothingOptimized
Holt
HoltWinters

Sparse or Intermittent

Suited for series with very few non-zero observations

Model Point Forecast Probabilistic Forecast Insample fitted values Probabilistic fitted values Exogenous features
ADIDA
CrostonClassic
CrostonOptimized
CrostonSBA
IMAPA
TSB

🔨 How to contribute

See CONTRIBUTING.md.

Citing

@misc{garza2022statsforecast,
    author={Federico Garza, Max Mergenthaler Canseco, Cristian Challú, Kin G. Olivares},
    title = {{StatsForecast}: Lightning fast forecasting with statistical and econometric models},
    year={2022},
    howpublished={{PyCon} Salt Lake City, Utah, US 2022},
    url={https://github.com/Nixtla/statsforecast}
}

Contributors ✨

Thanks goes to these wonderful people (emoji key):

fede
fede

💻 🚧
José Morales
José Morales

💻 🚧
Sugato Ray
Sugato Ray

💻
Jeff Tackes
Jeff Tackes

🐛
darinkist
darinkist

🤔
Alec Helyar
Alec Helyar

💬
Dave Hirschfeld
Dave Hirschfeld

💬
mergenthaler
mergenthaler

💻
Kin
Kin

💻
Yasslight90
Yasslight90

🤔
asinig
asinig

🤔
Philip Gillißen
Philip Gillißen

💻
Sebastian Hagn
Sebastian Hagn

🐛 📖
Han Wang
Han Wang

💻
Ben Jeffrey
Ben Jeffrey

🐛
Beliavsky
Beliavsky

📖
Mariana Menchero García
Mariana Menchero García

💻
Nikhil Gupta
Nikhil Gupta

🐛
JD
JD

🐛
josh attenberg
josh attenberg

💻
JeroenPeterBos
JeroenPeterBos

💻
Jeroen Van Der Donckt
Jeroen Van Der Donckt

💻
Roymprog
Roymprog

📖
Nelson Cárdenas Bolaño
Nelson Cárdenas Bolaño

📖
Kyle Schmaus
Kyle Schmaus

💻
Akmal Soliev
Akmal Soliev

💻
Nick To
Nick To

💻
Kevin Kho
Kevin Kho

💻
Yiben Huang
Yiben Huang

📖
Andrew Gross
Andrew Gross

📖
taniishkaaa
taniishkaaa

📖
Manuel Calzolari
Manuel Calzolari

💻

This project follows the all-contributors specification. Contributions of any kind 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

statsforecast-1.7.8.tar.gz (2.9 MB view hashes)

Uploaded Source

Built Distributions

statsforecast-1.7.8-cp312-cp312-win_amd64.whl (255.4 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

statsforecast-1.7.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (315.2 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

statsforecast-1.7.8-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (305.2 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

statsforecast-1.7.8-cp312-cp312-macosx_11_0_arm64.whl (274.2 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

statsforecast-1.7.8-cp312-cp312-macosx_10_13_x86_64.whl (289.0 kB view hashes)

Uploaded CPython 3.12 macOS 10.13+ x86-64

statsforecast-1.7.8-cp311-cp311-win_amd64.whl (254.7 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

statsforecast-1.7.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (315.8 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

statsforecast-1.7.8-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (305.9 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

statsforecast-1.7.8-cp311-cp311-macosx_11_0_arm64.whl (275.1 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

statsforecast-1.7.8-cp311-cp311-macosx_10_9_x86_64.whl (289.4 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

statsforecast-1.7.8-cp310-cp310-win_amd64.whl (253.5 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

statsforecast-1.7.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (314.7 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

statsforecast-1.7.8-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (304.8 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

statsforecast-1.7.8-cp310-cp310-macosx_11_0_arm64.whl (273.9 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

statsforecast-1.7.8-cp310-cp310-macosx_10_9_x86_64.whl (288.1 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

statsforecast-1.7.8-cp39-cp39-win_amd64.whl (251.8 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

statsforecast-1.7.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (314.9 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

statsforecast-1.7.8-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (305.0 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

statsforecast-1.7.8-cp39-cp39-macosx_11_0_arm64.whl (274.0 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

statsforecast-1.7.8-cp39-cp39-macosx_10_9_x86_64.whl (288.3 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

statsforecast-1.7.8-cp38-cp38-win_amd64.whl (253.6 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

statsforecast-1.7.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (313.6 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

statsforecast-1.7.8-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (305.0 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

statsforecast-1.7.8-cp38-cp38-macosx_11_0_arm64.whl (273.7 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

statsforecast-1.7.8-cp38-cp38-macosx_10_9_x86_64.whl (288.0 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

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