Time series forecasting suite using statistical models
Project description
Nixtla
Statistical ⚡️ Forecast
Lightning fast forecasting with statistical and econometric models
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
andTheta
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
andprediction 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
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):
This project follows the all-contributors specification. Contributions of any kind welcome!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for statsforecast-1.7.7-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31c4ea34b40ed9df15c0012f514925727a2e7a1c9cc5e9d2e8292edabf288adb |
|
MD5 | e123e76c54149f56b0cd9be7b97cc75e |
|
BLAKE2b-256 | cfce897c14dd15c751063a6059aeba53efbcc44412e740e904b2ab7131f014ad |
Hashes for statsforecast-1.7.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2acb441a28d5d6161ca81354b6b012eee18ab2468215fc59bd65f243ee2fb6e8 |
|
MD5 | a097bb0fec34512373532e0d1e23b96c |
|
BLAKE2b-256 | db24f7861d466830fdf43ff65c6a681e86b52dc7c8d31259765fe035dc5c3b92 |
Hashes for statsforecast-1.7.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bac5b98f6dfcdfa8dd74fbc43ac6d1c1b3884558ca59fd0403f356a68101646 |
|
MD5 | db33a5cb9d510c99751e55cbf261a25d |
|
BLAKE2b-256 | a4b3fbedaf66869f98d30f57cd2cd32e792aa85a7c7a1e57d23d9d7f2b2ed975 |
Hashes for statsforecast-1.7.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f186765789e69592a169141794484795f7b5500bf9eddd45c308b2a92e27209 |
|
MD5 | 628794081ad9b1049e42e81713db3096 |
|
BLAKE2b-256 | f3f5132d60ef7a21d28551c320005df35b2f2019f526c291779de9e1e640ab6c |
Hashes for statsforecast-1.7.7-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bec482350c00111e9c100ff361af9d3aa9984e0cda9164fe43a59ff2016d1ca |
|
MD5 | bf2f7d547d6ea78a542fa5314e965328 |
|
BLAKE2b-256 | abfb8df681a909e96bd0442394a601f9e94d9fa4052ec5e8873b6602f681bc53 |
Hashes for statsforecast-1.7.7-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 139c433ec655f0141b9c3c120d607966f1ec05c9048d5416579a73ae953203be |
|
MD5 | 3b7daceb5f97c9e7005db2c9c7235d22 |
|
BLAKE2b-256 | 23af8742044fd849f5261b514c8fdad1911412b49182729deb2200d452a793c7 |
Hashes for statsforecast-1.7.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d285140eb1528e75b96693999d5a62f88714e1c71d960cbbbb6c786630ba1de0 |
|
MD5 | 339a304fb19ef75837c7063c3629b606 |
|
BLAKE2b-256 | cf25087ce1676174f25cad08b7e404fedd09c7ba07033213c0b5b55682339ec6 |
Hashes for statsforecast-1.7.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72dc2f268ca141f2d6c73d98a511b3f1afe3c90a68dee15a2ae3289bb5d76ba1 |
|
MD5 | b442ae02a93718c9c64fed08fd0f81a0 |
|
BLAKE2b-256 | fabd0c2a6e35ab4cbce044acf083b9a3b4c2641313a573866a66c49cc6711ddd |
Hashes for statsforecast-1.7.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f6ae5e912a39b26a27fff8c235478ddf6bb3962590428bed05923d85eb3a3dc |
|
MD5 | 599b997a4cc7d590fd6686e4b4a999f2 |
|
BLAKE2b-256 | 8c714300b93c02e43c4504e1f7be6f0187fe02fe12c28a5e41d56969f812f3ea |
Hashes for statsforecast-1.7.7-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39b9de7c160b584174aad021ecf52ce5baf0669f15320462810043028dae5e2a |
|
MD5 | 1a290ec44a0bb9faceabdaa5d6fa0fda |
|
BLAKE2b-256 | d67f7723e2ad17ec4bcf3ead456e001006afe10ed7c133affb298b5118c0a968 |
Hashes for statsforecast-1.7.7-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a889fb582e722fa5a24098e6f7682fe4f827e46a5af7c94b07abe0ff1a83f1de |
|
MD5 | 0b96be751503310cf48160dbe9dce68d |
|
BLAKE2b-256 | 2c9ea2503f44995096951a91bbd9ab3d8aeb19d95fc3627e855a4aa622db504d |
Hashes for statsforecast-1.7.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca4c1226cac0de105ca874b3cc78f1a6120e49ae632a7db4cc41f1cf5aedd5a0 |
|
MD5 | 8f2a01fee4c213a1c20708b13588554e |
|
BLAKE2b-256 | 98225a308ccf6f0f05ab1c3ddf8238a8ae64e924f34d71b44d2bc5f978810353 |
Hashes for statsforecast-1.7.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e982bd653bd84e10f36f641c8dec6e24721755918e15553920131c975f10a576 |
|
MD5 | fc543960e67d449dc3ab352149bc1829 |
|
BLAKE2b-256 | 2480dcefaeff02e533785ae232a82729a101e547cbd83c41a1226e16f15a929d |
Hashes for statsforecast-1.7.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | adf95afea9dd86abfd58a9e95311f7b1a1b42120c075ae73b86ebc4dffe3e540 |
|
MD5 | 191baa4388438ad190117f5fe5079638 |
|
BLAKE2b-256 | 093920d2d970647a835443adfac0ddb4cf2e03a8b740831373ecf876a4c5dbd6 |
Hashes for statsforecast-1.7.7-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 723d1b4e9ff5bae689e19257993f4b8bf659b30d60970bd6d5919ada9ef84555 |
|
MD5 | cb85214952ed2f5f0b3ce6e5baec5eb1 |
|
BLAKE2b-256 | cc5a83beaca112cc6071089486d085378c95a2c0e7294ad98664aad60bfadb82 |
Hashes for statsforecast-1.7.7-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e48e7c0efcb3f8225d38e7d26fdfbc82c4e83522e8b47ade1f26ebd7612164a |
|
MD5 | c7dafe7fda257777783ddd871bb42eb7 |
|
BLAKE2b-256 | f2444ef706a0594d197d5640bb24e204f5faee475f84032e542281227e4bea83 |
Hashes for statsforecast-1.7.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e049d8eed069efc0117343615848e64bd7bfb697ea3356bb2853979b2fa811f6 |
|
MD5 | c101c4675bf90c66cbe7d2aea9e3245a |
|
BLAKE2b-256 | 7ce1fc826e8ee3b45482f4edd20446a73b0a67c2eefdaca97cea313892de75bd |
Hashes for statsforecast-1.7.7-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9ee2255982dbbd77eb58f6adc61809bc1b1b3b7aacef07aa42f84b13eda06ef |
|
MD5 | b61615482709b9b120136587239c5696 |
|
BLAKE2b-256 | 075faf7f6b155a0a0f78296f360a14d13675ca44c18898d82475e1c652c20a4f |
Hashes for statsforecast-1.7.7-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89cf7b1c21bc9f1bdb3af80c8ec036bfa44dff1cdc1802de8747134320d30e6f |
|
MD5 | 935c2412f56f97925219caab28cd1bbf |
|
BLAKE2b-256 | 5f363cca1991184af90ba7339f1df04472e28af883e9a53b24a1e30acf8622e9 |
Hashes for statsforecast-1.7.7-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 969a14b9d6c54ae2b326933fe9b650329fec73206a846f15e7b1656ce64984e0 |
|
MD5 | 2c7759e0960eabe4dd52ad89bee4d696 |
|
BLAKE2b-256 | 157489f619d835946074ee7f2c6f579073c57f5c2088416c41bae0447b5e8506 |
Hashes for statsforecast-1.7.7-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e589dc00f96a1484ef1b28b380581de6ad6fd8729c04108478a03be11406bf16 |
|
MD5 | ef3cc9c03e9037505579c65e0314ffb8 |
|
BLAKE2b-256 | 973393f3f1843f7aacd30ad8a240ba51e573d269f8059ad2eb7194fc3b15f934 |
Hashes for statsforecast-1.7.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ec943b1f63c7ab36b21e4df1bfcfad5462ea6876f0ca42d56a36939636cda0a |
|
MD5 | 80fb8ac2439505888faedc2323d620d6 |
|
BLAKE2b-256 | 4c317409b718eefda47fb2b22b532b007106f25a14d7ca213dfb144f611aa577 |
Hashes for statsforecast-1.7.7-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b600456ba45be16e93f41d2acdb0cd8f3362ed1bae3e5b05cb29e2bca04f0cfa |
|
MD5 | 917623ccff3369e62ae014f6a203df8b |
|
BLAKE2b-256 | 3680d7d9321787dbb88ec9bdbd0b53584384d84dee462b0f532a85b370647b62 |
Hashes for statsforecast-1.7.7-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4852231964bfc5b37f0e2b17feb3f919c30dbe6a9171be8f5afd28b4db4f7432 |
|
MD5 | faa9b0bba63c3b657b97d4773e4ceb8f |
|
BLAKE2b-256 | 69730d884d0e7a4838023cdf70810b799d33f066f740edad1f46c82f90d6bfa7 |
Hashes for statsforecast-1.7.7-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be9b5ced86657828a609427ac7f27a999403052cbf6bf0918b06401bf678437e |
|
MD5 | 229a8b7b8c46015c88840de67969766c |
|
BLAKE2b-256 | 39d9e18815237656ddf4372bf80270411b655a9eb02ee14b8c1201d700e9c1bb |