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.1-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a37f9aa187f96ba53a2ca2bea82473373cae3a5531b146f861a4d9a6371512d8 |
|
MD5 | 92d681c5fb26e23d74f3c0f080d08a69 |
|
BLAKE2b-256 | 2af792b0a9c177438943378f18c521bc7ada69fdb5dccf0ff85e70ef896cb275 |
Hashes for statsforecast-1.7.7.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8941ebc52fcd562bd070e4b2149a0868a04081505c21f75ef0e0f4dcd289018 |
|
MD5 | a3edd3b0a60ebaead3cc14be2ac4220e |
|
BLAKE2b-256 | 0310df204eeaa6c743814c0c102e981822465ebc4c13b250faf4358a8fef2c9a |
Hashes for statsforecast-1.7.7.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9f9069daab025c48903e32c33096a072285f8526161caa58c291d1961b0c941 |
|
MD5 | 301a03470fe07290f26649e1c50fd2b4 |
|
BLAKE2b-256 | cb455c9b52a8e2700170efbda903a511786ea4b3a186138eadb2bcab4c87e19b |
Hashes for statsforecast-1.7.7.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1085e8cd7010b6af80aadde21ff2fafccaeadd492dbc14bf200b0038dfef7794 |
|
MD5 | e3e56b7ac8d419f4914f5f91d35e57bf |
|
BLAKE2b-256 | 574a4c30e7ac6c09f2c778d4cdbc5e22dfcfbfede2f35b2545ca3dc205aa681c |
Hashes for statsforecast-1.7.7.1-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 996fd8f72420d3184869e0bc799b3fb82b7ff8b1f34e92403805b13456d7236a |
|
MD5 | 1ef82d4110d850f8a2adbea570353bb0 |
|
BLAKE2b-256 | 701be56e8603b44741f786e460b44dbf99d73c9de3ff2c0845e66800a92aea1c |
Hashes for statsforecast-1.7.7.1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8bf0fd5151c9a62f79acc0fad6d6288e6680249d0aeb6491fb1d663d4f9b506 |
|
MD5 | 816035c0b0a51b0a7fc5da7298e9d9ee |
|
BLAKE2b-256 | dca2e3aed50b5c176d8955e55eed4d6ecd13c7f0c325643a38f023f26eeac3c0 |
Hashes for statsforecast-1.7.7.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8951414b75dedd12065d1a1bead4fc827310f962c9d6b16b55ff0b3a3b44a60 |
|
MD5 | 209c915d0672448f9c51b5aae5ba63ba |
|
BLAKE2b-256 | 9cd81ed1d89c557753d1bfb447b0f76bed149b8c536eff9f806c715af747bd4a |
Hashes for statsforecast-1.7.7.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7a0c2b20faaf23f9770bb4ed9c5bb4408d204d03d6aad503ca5158552d696c9 |
|
MD5 | 602d71459654d6c001e23930b83059dd |
|
BLAKE2b-256 | 81a5db4eef370ee4c4ab7a5f1ff201056dc9b7014a5e4fc775893958a8307aac |
Hashes for statsforecast-1.7.7.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 292c8ed0fdbb63e2cd7ab1e164b4fd06d4570fce308843f40c7e5a4d550c1f00 |
|
MD5 | 5e583b0c017a705c6658a1de0aad3cf7 |
|
BLAKE2b-256 | 12ddd2fd15eadf3f970ba8b0c0ebb0efcb82fdcf50514724150ebea9f987da23 |
Hashes for statsforecast-1.7.7.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ad2359343fdee7a1f04c4f6cdefc6656eae4ba79348738abe5e1e025124eb50 |
|
MD5 | 2803ce65924b1b7c6bfa90ee4f61c6f6 |
|
BLAKE2b-256 | 75109e2fe32fa93e13ab5d87593edef478581d532f795e66be9e375c2f46e610 |
Hashes for statsforecast-1.7.7.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b345b7bdb95e6983d737af6749c7af821ac48ca77b6957998b301d7a9e3d113 |
|
MD5 | 4379c10f693f24890a04653b755978b1 |
|
BLAKE2b-256 | 185e59d907e7264e5e136ca9ae134e76b3d1d63d4a2e9ea43be4cd7931d90981 |
Hashes for statsforecast-1.7.7.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8011817a3a852a74546c5ab5c08796aa533cb1735a66d5b531b0091686f90b55 |
|
MD5 | 2efafb1316f224e2c2ce8f82a370df72 |
|
BLAKE2b-256 | 2284bdce2fee61d74265e22580c2edf2d7942186be511c147edf466de76603c8 |
Hashes for statsforecast-1.7.7.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f25d5da9205db630a5adbb7b8aac0b2ec2eeb0fc759eaa13a07752b84188cb0 |
|
MD5 | 581a3064421471c101380ea9055b4438 |
|
BLAKE2b-256 | 8ff645c99b3677003fd0144391f06ba1f32ffdcfaaa23bd96fd652b2eb6cdfe5 |
Hashes for statsforecast-1.7.7.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 020cfac84452702cafd5b94fcb676be331fdb4c7953bc03605e91b594bb795ff |
|
MD5 | 6f41a92fcdceff787eddfa4e5a4e089e |
|
BLAKE2b-256 | 0c9e3e99d42af598086e90c6254a9aae947c9ac7fb750e70d78a70ede7261a5f |
Hashes for statsforecast-1.7.7.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 882abf4db5e53aa25908f17ea2a9e0a7ce405d4c9abebb14752a2e7f5a989dec |
|
MD5 | eda37c8c85b640037dd72fcbdf89370f |
|
BLAKE2b-256 | 23247975ada7e85005eb37f944b7d4109113f410cb8ce853e17df1627fd42fba |
Hashes for statsforecast-1.7.7.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17da1bcc1c988c1e04a2f715c5916f694598521c9db30d568168180bc221ed55 |
|
MD5 | 44be2e241e13d1e0df5bc04b930ccab7 |
|
BLAKE2b-256 | a407e9e70cd4d218bfb12a5484f8834f1049bcb02ac024410c391068cd79c305 |
Hashes for statsforecast-1.7.7.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef2632701a7de6fc6fc05438681f3dcfc9449203f980c33de964bdbfa4c166c5 |
|
MD5 | 476b6ab8a14f1615b4bd8d80451fbc35 |
|
BLAKE2b-256 | a8f761b233458705c0243c24b85f712fbdc7d686349687227e54cba5239fcc96 |
Hashes for statsforecast-1.7.7.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01561ed69d30854e5b4ccc5d4dd8a9b7f9cef4141b1fe09b3ffed8a165fd6961 |
|
MD5 | c58ca87dc9dbe407da4a1a384691e499 |
|
BLAKE2b-256 | 7737843daf2e5b1e5f5725a70e4df67b9aa7e1cf611ab75f0ccf534a3cc04772 |
Hashes for statsforecast-1.7.7.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad3c686debe8f17fe4702038c1023c1babb0e1c28340952303cdfcc2a8a2f642 |
|
MD5 | a7a5d5e6b793874bc93a6df8091ff7c1 |
|
BLAKE2b-256 | f000154227eea95da07f0ab0a76188ee0f85750518867b01f16a3c27e0595495 |
Hashes for statsforecast-1.7.7.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 388b87730ed0abb81bcabdef0b960a2048ad3c083860ef549e48ea7cafa24638 |
|
MD5 | a2bb320609e7b4cbdf4825d6fa4b7cc8 |
|
BLAKE2b-256 | d55f25c38528f739328a88f44957909120bb7d73952af1eeb8acf16971d15957 |
Hashes for statsforecast-1.7.7.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24a4898d351dc5f495d8838aec74055bc1fa14bb78a28db00c24679400e117cf |
|
MD5 | d13d628044e7df49447a0f8e41debc61 |
|
BLAKE2b-256 | a761a5198b41a2cc3f362e9c036439a718601fbea93b8fe0bf3b48950272baaf |
Hashes for statsforecast-1.7.7.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45f758e935ec44975c91533348fa4235a3cb060a41ccd7219e1c801e140204c6 |
|
MD5 | 77152538071f6c2f33056d9cb2fb8f1c |
|
BLAKE2b-256 | 3c42c8fb4eb6684117a26156b50a1b19e9c02a3a8d5d0069a41f3ece4dc389ab |
Hashes for statsforecast-1.7.7.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a46922e6b2570e7894da68c9e2cf7fa91a313083d2e55f3bda7f8a36ecb9a87 |
|
MD5 | e1a9ba1a762c438f36a0dedbabdba70b |
|
BLAKE2b-256 | cef7695973276fce53cb79d3c8f0adbe437ca931160c98e914f45fc771696893 |
Hashes for statsforecast-1.7.7.1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64ba2942ace15771fd53d470d793c35550116dc09415b5d4255071c66c498c8f |
|
MD5 | 8d90ac5b63f8faa8a93dffa5a8161062 |
|
BLAKE2b-256 | 670eb0977bce37da42d419bffc01e1aacc4a7a7af882e8620ddf0aa4413831de |
Hashes for statsforecast-1.7.7.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4c559a40829eb186c0502c0c5af9f6bda5ece813435c5d7df30a9390567d25b |
|
MD5 | eb80f0934c5f8a313b5c485e4b559122 |
|
BLAKE2b-256 | 43ef0671bcee669e72c8cd52ae9646bf4d2e5e048643ce70cc6ef9c99882334e |