Skip to main content
2025 Python Packaging Survey is now live!  Take the survey now

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!

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