StatsForecast
StatsForecast is a Python library providing a lightning-fast suite of statistical and econometric models for time series forecasting. It offers highly optimized implementations of models like ARIMA, ETS, CES, and Theta, designed for speed and scalability to forecast millions of series efficiently. The library is currently at version 2.0.3 and maintains an active release cadence with frequent updates and performance enhancements.
Warnings
- breaking The default values for `allowmean` and `allowdrift` in `AutoARIMA` changed from `False` to `True` in `v2.0.0`. This can alter the behavior and results of your `AutoARIMA` forecasts if you were relying on the previous defaults.
- breaking The `df` argument has been removed from the `StatsForecast` class constructor as of `v2.0.3`. Instead, the DataFrame should be passed directly to the `fit`, `forecast`, or `cross_validation` methods.
- deprecated Pandas frequency alias 'H' (for hourly data) is deprecated and will be removed in a future version. Use 'h' instead.
- breaking Version 2.0.0 included a general breaking change to 'remove deprecated behavior' as part of refactoring. While specific impacts vary, it signals that code using previously deprecated features will likely break.
Install
-
pip install statsforecast
Imports
- StatsForecast
from statsforecast import StatsForecast
- AutoARIMA
from statsforecast.models import AutoARIMA
- AirPassengersDF
from statsforecast.utils import AirPassengersDF
Quickstart
import pandas as pd
from statsforecast import StatsForecast
from statsforecast.models import AutoARIMA
from statsforecast.utils import AirPassengersDF
# Load example data (AirPassengers dataset)
df = AirPassengersDF
# Instantiate StatsForecast with models and frequency
# For monthly data, 'M' or 'ME' (MonthEnd) is common
sf = StatsForecast(
models=[AutoARIMA(season_length=12)],
freq='M',
n_jobs=-1 # Use all available cores for parallel processing
)
# Fit the models
sf.fit(df)
# Make predictions for the next 12 steps (horizon=12)
# and calculate 95% prediction intervals
forecast_df = sf.predict(h=12, level=[95])
print(forecast_df.head())