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,MSTLandThetain 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:
.fitand.predict.
Highlights
- Inclusion of
exogenous variablesandprediction intervalsfor 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!
Metadata
Release files for statsforecast 1.7.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| statsforecast-1.7.4.tar.gz | 120.7 kB | Without provenance | Details for statsforecast-1.7.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| statsforecast-1.7.4-py3-none-any.whl | Python 3 | none | any | Details for statsforecast-1.7.4-py3-none-any.whl |
Total release size: 242.5 kB
Release files / statsforecast-1.7.4.tar.gz
| Download URL | statsforecast-1.7.4.tar.gz |
|---|---|
| Size | 120.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eaea757f0a8835bea5a710df02c3248c0bc0eff940ae8d83a46fc339abb52280
|
|
BLAKE2b-256 checksum How to use checksums |
7e2b57dab173b22c4f3513834458dc11005af8554f0dbb445bb981bf3b9b1e76
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|
Release files / statsforecast-1.7.4-py3-none-any.whl
| Download URL | statsforecast-1.7.4-py3-none-any.whl |
|---|---|
| Size | 121.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0863d371e87fdfaf0e157bfee5d242e9899365a50c558a30331ec0d965c0cc64
|
|
BLAKE2b-256 checksum How to use checksums |
4c6834dae7f9f36cd37abf87aea199ef1eb5591a090fc94865567fe4b86f0159
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|
Security for statsforecast 1.7.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.