StatsForecast provide a comprehensive interface for fitting, predicting, forecasting, and evaluating statistical forecasting models on large sets of time series.
Overview
The main methods include:StatsForecast.fit- Fit statistical modelsStatsForecast.predict- Predict using fitted modelsStatsForecast.forecast- Memory-efficient predictions without storing modelsStatsForecast.cross_validation- Temporal cross-validationStatsForecast.plot- Visualization of forecasts and historical data
StatsForecast Class
StatsForecast
Bases: _StatsForecast
The StatsForecast class allows you to efficiently fit multiple StatsForecast models
for large sets of time series. It operates on a DataFrame df with at least three columns:
ids, times, and targets.
The class has a memory-efficient StatsForecast.forecast method that avoids storing partial
model outputs, while the StatsForecast.fit and StatsForecast.predict methods with the
Scikit-learn interface store the fitted models.
The StatsForecast class offers parallelization utilities with Dask, Spark, and Ray back-ends.
See distributed computing example here.
StatsForecast.fit
predict method. This follows the scikit-learn fit/predict interface.
Parameters:
Returns:
StatsForecast.predict
fit method to generate predictions for the
specified forecast horizon. This follows the scikit-learn fit/predict interface.
Parameters:
Returns:
StatsForecast.fit_predict
fit and predict methods in a single operation. The fitted models
are stored internally in the fitted_ attribute for later use, making this method
suitable when you need both training and immediate predictions.
Parameters:
Returns:
StatsForecast.forecast
fit_predict
when you don’t need to inspect or reuse the fitted models. Models are trained and
used for forecasting within each time series, then discarded.
Parameters:
Returns:
StatsForecast.cross_validation
Returns:
StatsForecast.plot
Returns:
StatsForecast.save
load() method
to restore the exact state for making predictions.
Parameters:
StatsForecast.load
save() method,
restoring all fitted models and configuration. The loaded object is ready to
generate predictions immediately.
Parameters:
Returns:
Usage Examples
Basic Forecasting
Cross-Validation
Prediction Intervals
Conformal Prediction Intervals
Advanced Features
Integer Datestamps
TheStatsForecast class can work with integer datestamps instead of datetime objects:
External Regressors
Every column aftery is considered an external regressor and will be passed to models that support them:
Distributed Computing
TheStatsForecast class offers parallelization utilities with Dask, Spark and Ray backends for distributed computing. See the distributed computing examples for more information.
