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.8-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1815e702096e5da75add79c81b3cc867954f3a957c921836035a78065f8e720e |
|
MD5 | 13c2d93138e74aad67301bd5b83ae5d2 |
|
BLAKE2b-256 | e6ab5de37ea549895b9ee5701ac45bb7aff47ec7838754ab468188af7253b699 |
Hashes for statsforecast-1.7.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c949af0b8b299bd1cf541de9b718c9f4ad627cd858fbda0a14bc4fd5d390241e |
|
MD5 | c37f91e56f2ef42b24e37b03e8239161 |
|
BLAKE2b-256 | 6b6fe70e0f3937ecbe65f353ba3df5385f6996e240fb366d3a2e1cfd7cc2daf4 |
Hashes for statsforecast-1.7.8-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6eda1b19e9230925766d2f247ab64d873af09ba0db56d8ddf2705aa78e4d59b1 |
|
MD5 | 6dd2b4d8412a4a67fd58377321a9b0ea |
|
BLAKE2b-256 | 44d0f96049db657cb1f17f6513dc2bcd4d647ce10dcf2225260b23d1b3210ac7 |
Hashes for statsforecast-1.7.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a598bedc662ae892d5ab050352746805a731a8aec511a6771cf03b1f4d76e3f2 |
|
MD5 | 6d65535bc51f0e7f226b54946deb2781 |
|
BLAKE2b-256 | a5f5e18a4a5d1023159411c0080095b1ee673e6f78493f1ad5c32b2e17ebe1d8 |
Hashes for statsforecast-1.7.8-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33eace24080e559ac410fbed361cabfe688cb2f9b9a2e2f20aca19dcbc20be0d |
|
MD5 | 3d0ba26f34f1ee03c39ea0d80dd353ca |
|
BLAKE2b-256 | 0eff908343552251642c8d2dd374e5b909d2c2d16ba6abc60f9d2a24076c65e9 |
Hashes for statsforecast-1.7.8-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da74148ab2e398ad4310c12fa34517477ad20fc49b935f63c330da2e94380c9f |
|
MD5 | d6c9f1445519e2b2a2420ab1f7da3fbb |
|
BLAKE2b-256 | de7c4e56c0c5aa11f73cebd5e49ec55cc7be6799c559a290d2eac893cef18394 |
Hashes for statsforecast-1.7.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84bc52363d66ece211e6d196eb764fceb097384a192031be866bea02f7e62c4d |
|
MD5 | 2888851d063ab7d722a65261cde1eca1 |
|
BLAKE2b-256 | 8b0afd4477e16c0d9509d503891dbba2baf73f4b17426850c3c02350a18ab049 |
Hashes for statsforecast-1.7.8-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa02344b08e71497ddc562b023ab627b3703f035fd703dad3e5a0f6e94cb8c7f |
|
MD5 | cb8d30462cd98bac75070aa85dc39ca3 |
|
BLAKE2b-256 | a80f62317fadd4b5d9e1fe0b88d352cbad2e254a5c9ebfbba6d379d2096a8110 |
Hashes for statsforecast-1.7.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 725ebea30e9098c812dfbc85dc31a5b459d46d3b81e68212899894770f27648a |
|
MD5 | 92eed6e6bb9e4554e3ede5f4415e9cdd |
|
BLAKE2b-256 | fb8198990339028ee547a1d5b155f411d42b29df5cb6bad80830accb665dad09 |
Hashes for statsforecast-1.7.8-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 737c99fff0e881fb1713e7f38e5d3b523a6451650564706eef91ce647d5a8d74 |
|
MD5 | 41155bec787e7082088166fb370f6687 |
|
BLAKE2b-256 | b39ef71462cc00622b653bd9d1865b08840140267389f6fe50adcf9c8a5935fe |
Hashes for statsforecast-1.7.8-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e020832403530e5be74f44738d792c043faecc2718e71cc6cf1372f361210f64 |
|
MD5 | 665a671b70af21683eb5853b5cb368f3 |
|
BLAKE2b-256 | 2f9c9bc8b708ddf7ba852448ea821cf6ba04f9f482462bd0b6f9bd0d4c00e5f8 |
Hashes for statsforecast-1.7.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 892413f04f48c6036ebefb759cf676b0cf98ce6079c3f1a55795eba3a06d20b2 |
|
MD5 | 760364745a5c6c467d02a19dc7535488 |
|
BLAKE2b-256 | 87dda5fc68cc69a1c81e545d44ba74fd0c6a4e3a69db27ef7fb35e10d6de1ca0 |
Hashes for statsforecast-1.7.8-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12f1bea7e1a23ca425476dfcf17dc56a44462ce0284f8c6f82c65b49c5c23b0b |
|
MD5 | 09ad4991e3efccc82d7e8100f38e87e4 |
|
BLAKE2b-256 | a535e662883ae62829f921cd93f7007b955206c2c46006f51ecd07ffa108ee84 |
Hashes for statsforecast-1.7.8-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a205baeac2db8afae70a67498c9ec89762525d88c741e323af5a539e4260cc61 |
|
MD5 | b9aba6ade8f2c935f771a51b6dc2ade7 |
|
BLAKE2b-256 | 6cc5d1891f334d500647ab05e9e5dea0b89724097d859b031051c7822d75c6e3 |
Hashes for statsforecast-1.7.8-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79e5683a43265edd55d71b31bc602b29e8e38e61d0c9ef4b9000056ab6b8534e |
|
MD5 | 2ed3ec3f9382b71ab2b4d28dbbf9c366 |
|
BLAKE2b-256 | 240559d9bfe4586f006ac5d06d7a6e1760f6ca5f31208bace43b64eff55c647a |
Hashes for statsforecast-1.7.8-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a4f6364e3542109a46efc4c67f28a2172e0b3805b4001595207a0f8fa08c715 |
|
MD5 | 08aa74d1d1385adfc34c9888392fa3b1 |
|
BLAKE2b-256 | 10dd8f16affb59ff29693f94e106e414e42f029bef48ca5aa842f4d0822f0d51 |
Hashes for statsforecast-1.7.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90df1972fcc6fe945a0e80398174f9a88fefc3ef1980e24a045e7029e9cf1eb2 |
|
MD5 | 4e936289cd51a07f1613c1983aac7ede |
|
BLAKE2b-256 | eebf95e92580072ed8cc0998beac933425c9dc78faf0f0998686cf8303e3e24d |
Hashes for statsforecast-1.7.8-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77f4d9d32c5c4df65720a71721af405f4d348f341ade89d1cabbdc7f02af73a9 |
|
MD5 | 1c9785455ef6dd2dc12ad68a64edc6b8 |
|
BLAKE2b-256 | 3d06061e189b0d0d82f257f635f6a3f00a39dea962dd13a58e2674fae6275d20 |
Hashes for statsforecast-1.7.8-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b51895e1dd88ab8abe0c43135822e4f5eafd0a903387407c21eda9e610cf00af |
|
MD5 | 7f5662352c4ab68e37c68c20118816ab |
|
BLAKE2b-256 | f13b8a2f0ec9ff5295e5541ed7ebb0587a3aa16c6310b5ea4b093354cda2fbfd |
Hashes for statsforecast-1.7.8-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34351e94006ad83fac45a78667731923b131bed5149b9f96c6bf249117b7612e |
|
MD5 | 825d93273da12e87090d31a38e6725b2 |
|
BLAKE2b-256 | 9bb6e347ad8203a6157d2846ceb0b246d46b58d7c14b23030f32e899b0bef4e3 |
Hashes for statsforecast-1.7.8-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be8383b621bd5805ae003bfacded6c9eb3bb156d6948c27077cedd58314b862f |
|
MD5 | a6bc5f24845ada5141019480e187874a |
|
BLAKE2b-256 | fe4a351eff0c4b3b3ada7e5d00d0a64937d3151fb7a8c60052a17c0c951dd58a |
Hashes for statsforecast-1.7.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d24b2a1f8e88bbeda3905bae7adc9ccffce40bbf10b64bd1121600fed958b9fa |
|
MD5 | 9562e607ae603d16d6a13580b841a907 |
|
BLAKE2b-256 | c7e1097d1ef07733808ee5f73843334ab977dbbf9f231c91be2f5e2d94ec0851 |
Hashes for statsforecast-1.7.8-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fa9babfd8fb046912d2dde747f79f1957c20b717fc65a9f91c9994d8db6a737 |
|
MD5 | 1eeabfd816b3c2afd8bccd506d3b708f |
|
BLAKE2b-256 | 3eaf570719df38f8a26a1b992ddb67710cf155d35ea4c10fa6a8fa63e436ab09 |
Hashes for statsforecast-1.7.8-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 785c08a87bacbb4613b8e5d8273f6b31e2e8f3752f651bd695219d43656b6738 |
|
MD5 | 3830555ea949c7916314eab7f385c3eb |
|
BLAKE2b-256 | 0d555baad59eeda756bd17d972dfc55b8716821355977df7a96991fb9e1f0838 |
Hashes for statsforecast-1.7.8-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 656f9bbd328557aec776c8ce90f1a0c7601b4ca391454eae348c24ae88f7a1d5 |
|
MD5 | 604dc9b2944b1a6a3c954ca53e6cf2c9 |
|
BLAKE2b-256 | c8b6bdcc02a7949dd5389065433dcc28cb5f99ed1401ba57e95eb52e9085ce95 |