Documentation Index
Fetch the complete documentation index at: https://nixtlaverse.nixtla.io/llms.txt
Use this file to discover all available pages before exploring further.
StatsForecast offers a wide variety of statistical forecasting models grouped into the following categories:
-
Auto Forecast: Automatic forecasting tools that search for the best parameters and select the best possible model. Useful for large collections of univariate time series. Includes: AutoARIMA, AutoETS, AutoTheta, AutoCES, AutoMFLES, AutoTBATS.
-
ARIMA Family: AutoRegressive Integrated Moving Average models for capturing autocorrelations in time series data.
-
Exponential Smoothing: Uses weighted averages of past observations where weights decrease exponentially into the past. Suitable for data with clear trend and/or seasonality.
-
Baseline Models: Classical models for establishing baselines: HistoricAverage, Naive, RandomWalkWithDrift, SeasonalNaive, WindowAverage, SeasonalWindowAverage.
-
Sparse or Intermittent: Models suited for series with very few non-zero observations: ADIDA, CrostonClassic, CrostonOptimized, CrostonSBA, IMAPA, TSB.
-
Multiple Seasonalities: Models suited for signals with more than one clear seasonality. Useful for low-frequency data like electricity and logs: MSTL, MFLES, TBATS.
-
Theta Models: Fit two theta lines to a deseasonalized time series using different techniques: Theta, OptimizedTheta, DynamicTheta, DynamicOptimizedTheta.
-
ARCH/GARCH Family: Models for time series exhibiting non-constant volatility over time. Commonly used in finance.
-
Machine Learning: Wrapper for scikit-learn models to be used with StatsForecast.
Automatic Forecasting
AutoARIMA
AutoARIMA
AutoARIMA(d=None, D=None, max_p=5, max_q=5, max_P=2, max_Q=2, max_order=5, max_d=2, max_D=1, start_p=2, start_q=2, start_P=1, start_Q=1, stationary=False, seasonal=True, ic='aicc', stepwise=True, nmodels=94, trace=False, approximation=False, method=None, truncate=None, test='kpss', test_kwargs=None, seasonal_test='seas', seasonal_test_kwargs=None, allowdrift=True, allowmean=True, blambda=None, biasadj=False, season_length=1, alias='AutoARIMA', prediction_intervals=None)
Bases: _TS
AutoARIMA model.
Automatically selects the best ARIMA (AutoRegressive Integrated Moving Average)
model using an information criterion. Default is Akaike Information Criterion (AICc).
Parameters:
| Name | Type | Description | Default |
|---|
d | Optional[int] | Order of first-differencing. | None |
D | Optional[int] | Order of seasonal-differencing. | None |
max_p | int, default=5 | Max autorregresives p. | 5 |
max_q | int, default=5 | Max moving averages q. | 5 |
max_P | int, default=2 | Max seasonal autorregresives P. | 2 |
max_Q | int, default=2 | Max seasonal moving averages Q. | 2 |
max_order | int, default=5 | Max p+q+P+Q value if not stepwise selection. | 5 |
max_d | int, default=2 | Max non-seasonal differences. | 2 |
max_D | int, default=1 | Max seasonal differences. | 1 |
start_p | int, default=2 | Starting value of p in stepwise procedure. | 2 |
start_q | int, default=2 | Starting value of q in stepwise procedure. | 2 |
start_P | int, default=1 | Starting value of P in stepwise procedure. | 1 |
start_Q | int, default=1 | Starting value of Q in stepwise procedure. | 1 |
stationary | bool, default=False | If True, restricts search to stationary models. | False |
seasonal | bool, default=True | If False, restricts search to non-seasonal models. | True |
ic | str, default=“aicc” | Information criterion to be used in model selection. | ‘aicc’ |
stepwise | bool, default=True | If True, will do stepwise selection (faster). | True |
nmodels | int, default=94 | Number of models considered in stepwise search. | 94 |
trace | bool, default=False | If True, the searched ARIMA models is reported. | False |
approximation | Optional[bool], default=False | If True, conditional sums-of-squares estimation, final MLE. | False |
method | Optional[str] | Fitting method between maximum likelihood or sums-of-squares. | None |
truncate | Optional[bool] | Observations truncated series used in model selection. | None |
test | str, default=“kpss” | Unit root test to use. See ndiffs for details. | ‘kpss’ |
test_kwargs | Optional[str] | Unit root test additional arguments. | None |
seasonal_test | str, default=“seas” | Selection method for seasonal differences. | ‘seas’ |
seasonal_test_kwargs | Optional[dict] | Seasonal unit root test arguments. | None |
allowdrift | bool, default=True | If True, drift models terms considered. | True |
allowmean | bool, default=True | If True, non-zero mean models considered. | True |
blambda | Optional[float] | Box-Cox transformation parameter. | None |
biasadj | bool, default=False | Use adjusted back-transformed mean Box-Cox. | False |
season_length | int, default=1 | Number of observations per unit of time. Ex: 24 Hourly data. | 1 |
alias | str, default=“AutoARIMA” | Custom name of the model. | ‘AutoARIMA’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. | None |
AutoARIMA.fit
Fit the AutoARIMA model.
Fit an AutoARIMA to a time series (numpy array) y
and optionally exogenous variables (numpy array) X.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
X | array - like | Optional exogenous of shape (t, n_x). | None |
Returns:
| Name | Type | Description |
|---|
AutoARIMA | | AutoARIMA fitted model. |
AutoARIMA.predict
predict(h, X=None, level=None)
Predict with fitted AutoArima.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | array - like | Optional exogenous of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
AutoARIMA.predict_in_sample
predict_in_sample(level=None)
Access fitted AutoArima insample predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries fitted for point predictions and level_* for probabilistic predictions. |
AutoARIMA.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient AutoARIMA predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (n, ). | required |
h | int | Forecast horizon. | required |
X | array - like | Optional insample exogenpus of shape (t, n_x). | None |
X_future | array - like | Optional exogenous of shape (h, n_x) optional exogenous. | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
fitted | bool, default=False | Whether or not returns insample predictions. | False |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
AutoETS
AutoETS
AutoETS(season_length=1, model='ZZZ', damped=None, phi=None, alias='AutoETS', prediction_intervals=None)
Bases: _TS
Automatic Error, Trend, Seasonal Model.
Automatically selects the best ETS (Error, Trend, Seasonality)
model using an information criterion. Default is Akaike Information Criterion (AICc), while particular models are estimated using maximum likelihood.
The state-space equations can be determined based on their M multiplicative, A additive,
Z optimized or N ommited components. The model string parameter defines the ETS equations:
E in [M,A,Z], T in [N,A,M,Z], and S in [N,A,M,Z].
For example when model=‘ANN’ (additive error, no trend, and no seasonality), ETS will
explore only a simple exponential smoothing.
If the component is selected as ‘Z’, it operates as a placeholder to ask the AutoETS model
to figure out the best parameter.
Parameters:
| Name | Type | Description | Default |
|---|
season_length | int, default=1 | Number of observations per unit of time. Ex: 24 Hourly data. | 1 |
model | str, default=“ZZZ” | Controlling state-space-equations. | ‘ZZZ’ |
damped | bool | A parameter that ‘dampens’ the trend. | None |
phi | float | Smoothing parameter for trend damping. Only used when damped=True. | None |
alias | str, default=“AutoETS” | Custom name of the model. | ‘AutoETS’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. | None |
AutoETS.fit
Fit the Exponential Smoothing model.
Fit an Exponential Smoothing model to a time series (numpy array) y
and optionally exogenous variables (numpy array) X.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
X | array - like | Optional exogenous of shape (t, n_x). | None |
Returns:
| Name | Type | Description |
|---|
AutoETS | | Exponential Smoothing fitted model. |
AutoETS.predict
predict(h, X=None, level=None)
Predict with fitted Exponential Smoothing.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | array - like | Optional exogenpus of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
AutoETS.predict_in_sample
predict_in_sample(level=None)
Access fitted Exponential Smoothing insample predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries fitted for point predictions and level_* for probabilistic predictions. |
AutoETS.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient Exponential Smoothing predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (n, ). | required |
h | int | Forecast horizon. | required |
X | array - like | Optional insample exogenpus of shape (t, n_x). | None |
X_future | array - like | Optional exogenous of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
fitted | bool, default=False | Whether or not returns insample predictions. | False |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
AutoCES
AutoCES
AutoCES(season_length=1, model='Z', alias='CES', prediction_intervals=None)
Bases: _TS
Complex Exponential Smoothing model.
Automatically selects the best Complex Exponential Smoothing
model using an information criterion. Default is Akaike Information Criterion (AICc), while particular
models are estimated using maximum likelihood.
The state-space equations can be determined based on their S simple, P parial,
Z optimized or N ommited components. The model string parameter defines the
kind of CES model: N for simple CES (withous seasonality), S for simple seasonality (lagged CES),
P for partial seasonality (without complex part), F for full seasonality (lagged CES
with real and complex seasonal parts).
If the component is selected as ‘Z’, it operates as a placeholder to ask the AutoCES model
to figure out the best parameter.
Parameters:
| Name | Type | Description | Default |
|---|
season_length | int, default=1 | Number of observations per unit of time. Ex: 24 Hourly data. | 1 |
model | str, default=“Z” | Controlling state-space-equations. | ‘Z’ |
alias | str, default=“CES” | Custom name of the model. | ‘CES’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. | None |
AutoCES.fit
Fit the Complex Exponential Smoothing model.
Fit the Complex Exponential Smoothing model to a time series (numpy array) y
and optionally exogenous variables (numpy array) X.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
X | array - like | Optional exogenous of shape (t, n_x). | None |
Returns:
| Name | Type | Description |
|---|
AutoCES | | Complex Exponential Smoothing fitted model. |
AutoCES.predict
predict(h, X=None, level=None)
Predict with fitted Exponential Smoothing.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | array - like | Optional exogenous of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
AutoCES.predict_in_sample
predict_in_sample(level=None)
Access fitted Exponential Smoothing insample predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries fitted for point predictions and level_* for probabilistic predictions. |
AutoCES.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient Complex Exponential Smoothing predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (n, ). | required |
h | int | Forecast horizon. | required |
X | array - like | Optional insample exogenous of shape (t, n_x). | None |
X_future | array - like | Optional exogenpus of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
fitted | bool, default=False | Whether or not to return insample predictions. | False |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
AutoTheta
AutoTheta
AutoTheta(season_length=1, decomposition_type='multiplicative', model=None, alias='AutoTheta', prediction_intervals=None)
Bases: _TS
AutoTheta model.
Automatically selects the best Theta (Standard Theta Model (‘STM’),
Optimized Theta Model (‘OTM’), Dynamic Standard Theta Model (‘DSTM’),
Dynamic Optimized Theta Model (‘DOTM’)) model using mse.
Parameters:
| Name | Type | Description | Default |
|---|
season_length | int, default=1 | Number of observations per unit of time. Ex: 24 Hourly data. | 1 |
decomposition_type | str, default=“multiplicative” | Sesonal decomposition type, ‘multiplicative’ (default) or ‘additive’. | ‘multiplicative’ |
model | Optional[str] | Controlling Theta Model. By default searchs the best model. | None |
alias | str, default=“AutoTheta” | Custom name of the model. | ‘AutoTheta’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. | None |
AutoTheta.fit
Fit the AutoTheta model.
Fit an AutoTheta model to a time series (numpy array) y
and optionally exogenous variables (numpy array) X.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
X | array - like | Optional exogenous of shape (t, n_x). | None |
Returns:
| Name | Type | Description |
|---|
AutoTheta | | AutoTheta fitted model. |
AutoTheta.predict
predict(h, X=None, level=None)
Predict with fitted AutoTheta.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | array - like | Optional exogenous of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
AutoTheta.predict_in_sample
predict_in_sample(level=None)
Access fitted AutoTheta insample predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries fitted for point predictions and level_* for probabilistic predictions. |
AutoTheta.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient AutoTheta predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (n, ). | required |
h | int | Forecast horizon. | required |
X | array - like | Optional insample exogenous of shape (t, n_x). | None |
X_future | array - like | Optional exogenous of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
fitted | bool, default=False | Whether or not returns insample predictions. | False |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
AutoMFLES
AutoMFLES
AutoMFLES(test_size, season_length=None, n_windows=2, config=None, step_size=None, metric='smape', verbose=False, prediction_intervals=None, alias='AutoMFLES')
Bases: _TS
AutoMFLES
Parameters:
| Name | Type | Description | Default |
|---|
test_size | int | Forecast horizon used during cross validation. | required |
season_length | int or list of int, optional, default=None | Number of observations per unit of time. Ex: 24 Hourly data. | None |
n_windows | int, default=2 | Number of windows used for cross validation. | 2 |
config | dict, optional, default=None | Mapping from parameter name (from the init arguments of MFLES) to a list of values to try. If None, will use defaults. | None |
step_size | int, optional, default=None | Step size between each cross validation window. If None will be set to test_size. | None |
metric | str, default=‘smape’ | Metric used to select the best model. Possible options are: ‘smape’, ‘mape’, ‘mse’ and ‘mae’. | ‘smape’ |
verbose | bool, default=False | Print debugging information. | False |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. This is required for generating future prediction intervals. | None |
alias | str, default=‘AutoMFLES’ | Custom name of the model. | ‘AutoMFLES’ |
AutoMFLES.fit
Fit the model
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
X | array-like, optional, default=None | Exogenous of shape (t, n_x). | None |
Returns:
| Name | Type | Description |
|---|
AutoMFLES | AutoMFLES | Fitted AutoMFLES object. |
AutoMFLES.predict
predict(h, X=None, level=None)
Predict with fitted AutoMFLES.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | array-like, optional, default=None | Exogenous of shape (h, n_x). | None |
level | List[int] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | Dict[str, Any] | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
AutoMFLES.predict_in_sample
predict_in_sample(level=None)
Access fitted AutoMFLES insample predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | List[int] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | Dict[str, Any] | Dictionary with entries fitted for point predictions and level_* for probabilistic predictions. |
AutoMFLES.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient AutoMFLES predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
h | int | Forecast horizon. | required |
X | array - like | Insample exogenous of shape (t, n_x). | None |
X_future | array - like | Exogenous of shape (h, n_x). | None |
level | List[int] | Confidence levels (0-100) for prediction intervals. | None |
fitted | bool, default=False | Whether or not to return insample predictions. | False |
Returns:
| Name | Type | Description |
|---|
dict | Dict[str, Any] | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
AutoTBATS
AutoTBATS
AutoTBATS(season_length, use_boxcox=None, bc_lower_bound=0.0, bc_upper_bound=1.0, use_trend=None, use_damped_trend=None, use_arma_errors=True, alias='AutoTBATS')
Bases: _TS
AutoTBATS model.
Automatically selects the best TBATS model from all feasible combinations of the parameters use_boxcox, use_trend, use_damped_trend, and use_arma_errors.
Selection is made using the AIC.
Default value for use_arma_errors is True since this enables the evaluation of models with and without ARMA errors.
Parameters:
| Name | Type | Description | Default |
|---|
seasonal_periods | int or list of int | Number of observations per unit of time. Ex: 24 Hourly data. | required |
use_boxcox | bool, default=None | Whether or not to use a Box-Cox transformation. By default tries both. | None |
bc_lower_bound | float, default=0.0 | Lower bound for the Box-Cox transformation. | 0.0 |
bc_upper_bound | float, default=1.0 | Upper bound for the Box-Cox transformation. | 1.0 |
use_trend | bool, default=None | Whether or not to use a trend component. By default tries both. | None |
use_damped_trend | bool, default=None | Whether or not to dampen the trend component. By default tries both. | None |
use_arma_errors | bool, default=True | Whether or not to use a ARMA errors. Default is True and this evaluates both models. | True |
alias | str | Custom name of the model. | ‘AutoTBATS’ |
AutoTBATS.fit
Fit TBATS model.
Fit TBATS model to a time series (numpy array) y.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
X | numpy.array, optional, default=None | Ignored | None |
Returns:
| Name | Type | Description |
|---|
self | | TBATS model. |
AutoTBATS.predict
predict(h, X=None, level=None)
Predict with fitted TBATS model.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
forecasts | dict | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
AutoTBATS.predict_in_sample
predict_in_sample(level=None)
Access fitted TBATS model predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
forecasts | dict | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
AutoTBATS.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient TBATS model.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (n, ). | required |
h | int | Forecast horizon. | required |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
fitted | bool | Whether or not returns insample predictions. | False |
Returns:
| Name | Type | Description |
|---|
forecasts | dict | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
ARIMA Family
ARIMA
ARIMA
ARIMA(order=(0, 0, 0), season_length=1, seasonal_order=(0, 0, 0), include_mean=True, include_drift=False, include_constant=None, blambda=None, biasadj=False, method='CSS-ML', fixed=None, alias='ARIMA', prediction_intervals=None)
Bases: _TS
ARIMA model.
AutoRegressive Integrated Moving Average model.
Parameters:
| Name | Type | Description | Default |
|---|
order | tuple, default=(0, 0, 0) | A specification of the non-seasonal part of the ARIMA model: the three components (p, d, q) are the AR order, the degree of differencing, and the MA order. | (0, 0, 0) |
season_length | int, default=1 | Number of observations per unit of time. Ex: 24 Hourly data. | 1 |
seasonal_order | tuple, default=(0, 0, 0) | A specification of the seasonal part of the ARIMA model. (P, D, Q) for the AR order, the degree of differencing, the MA order. | (0, 0, 0) |
include_mean | bool, default=True | Should the ARIMA model include a mean term? The default is True for undifferenced series, False for differenced ones (where a mean would not affect the fit nor predictions). | True |
include_drift | bool, default=False | Should the ARIMA model include a linear drift term? (i.e., a linear regression with ARIMA errors is fitted.) | False |
include_constant | bool, optional, default=None | If True, then includ_mean is set to be True for undifferenced series and include_drift is set to be True for differenced series. Note that if there is more than one difference taken, no constant is included regardless of the value of this argument. This is deliberate as otherwise quadratic and higher order polynomial trends would be induced. | None |
blambda | float, optional, default=None | Box-Cox transformation parameter. | None |
biasadj | bool, default=False | Use adjusted back-transformed mean Box-Cox. | False |
method | str, default=‘CSS-ML’ | Fitting method: maximum likelihood or minimize conditional sum-of-squares. The default (unless there are missing values) is to use conditional-sum-of-squares to find starting values, then maximum likelihood. | ‘CSS-ML’ |
fixed | dict, optional, default=None | Dictionary containing fixed coefficients for the arima model. Example: {'ar1': 0.5, 'ma2': 0.75}. For autoregressive terms use the ar{i} keys. For its seasonal version use sar{i}. For moving average terms use the ma{i} keys. For its seasonal version use sma{i}. For intercept and drift use the intercept and drift keys. For exogenous variables use the ex_{i} keys. | None |
alias | str | Custom name of the model. | ‘ARIMA’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. | None |
ARIMA.fit
Fit the model to a time series (numpy array) y
and optionally exogenous variables (numpy array) X.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
X | array - like | Optional exogenous of shape (t, n_x). | None |
Returns:
| Name | Type | Description |
|---|
self | | Fitted model. |
ARIMA.predict
predict(h, X=None, level=None)
Predict with fitted model.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | array - like | Optional exogenous of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
forecasts | dict | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
ARIMA.predict_in_sample
predict_in_sample(level=None)
Access fitted insample predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
forecasts | dict | Dictionary with entries fitted for point predictions and level_* for probabilistic predictions. |
ARIMA.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory efficient predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (n, ). | required |
h | int | Forecast horizon. | required |
X | array - like | Optional insample exogenous of shape (t, n_x). | None |
X_future | array - like | Optional exogenous of shape (h, n_x) optional exogenous. | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
fitted | bool | Whether or not returns insample predictions. | False |
Returns:
| Name | Type | Description |
|---|
forecasts | dict | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
AutoRegressive
AutoRegressive
AutoRegressive(lags, include_mean=True, include_drift=False, blambda=None, biasadj=False, method='CSS-ML', fixed=None, alias='AutoRegressive', prediction_intervals=None)
Bases: ARIMA
Simple Autoregressive model.
Parameters:
| Name | Type | Description | Default |
|---|
lags | int or list | Number of lags to include in the model. If an int is passed then all lags up to lags are considered. If a list, only the elements of the list are considered as lags. | required |
include_mean | bool, default=True | Should the AutoRegressive model include a mean term? The default is True for undifferenced series, False for differenced ones (where a mean would not affect the fit nor predictions). | True |
include_drift | bool, default=False | Should the AutoRegressive model include a linear drift term? (i.e., a linear regression with AutoRegressive errors is fitted.) | False |
blambda | float, optional, default=None | Box-Cox transformation parameter. | None |
biasadj | bool, default=False | Use adjusted back-transformed mean Box-Cox. | False |
method | str, default=‘CSS-ML’ | Fitting method: maximum likelihood or minimize conditional sum-of-squares. The default (unless there are missing values) is to use conditional-sum-of-squares to find starting values, then maximum likelihood. | ‘CSS-ML’ |
fixed | dict, optional, default=None | Dictionary containing fixed coefficients for the AutoRegressive model. Example: {'ar1': 0.5, 'ar5': 0.75}. For autoregressive terms use the ar{i} keys. | None |
alias | str | Custom name of the model. | ‘AutoRegressive’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. | None |
AutoRegressive.fit
Fit the model to a time series (numpy array) y
and optionally exogenous variables (numpy array) X.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
X | array - like | Optional exogenous of shape (t, n_x). | None |
Returns:
| Name | Type | Description |
|---|
self | | Fitted model. |
AutoRegressive.predict
predict(h, X=None, level=None)
Predict with fitted model.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | array - like | Optional exogenous of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
forecasts | dict | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
AutoRegressive.predict_in_sample
predict_in_sample(level=None)
Access fitted insample predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
forecasts | dict | Dictionary with entries fitted for point predictions and level_* for probabilistic predictions. |
AutoRegressive.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory efficient predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (n, ). | required |
h | int | Forecast horizon. | required |
X | array - like | Optional insample exogenous of shape (t, n_x). | None |
X_future | array - like | Optional exogenous of shape (h, n_x) optional exogenous. | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
fitted | bool | Whether or not returns insample predictions. | False |
Returns:
| Name | Type | Description |
|---|
forecasts | dict | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
Exponential Smoothing
SimpleExponentialSmoothing
SimpleExponentialSmoothing
SimpleExponentialSmoothing(alpha, alias='SES', prediction_intervals=None)
Bases: _TS
SimpleExponentialSmoothing model.
Uses a weighted average of all past observations where the weights decrease exponentially into the past.
Suitable for data with no clear trend or seasonality.
Assuming there are t observations, the one-step forecast is given by: hatyt+1=alphayt+(1−alpha)hatyt−1
The rate 0leqalphaleq1 at which the weights decrease is called the smoothing parameter. When alpha=1, SES is equal to the naive method.
Parameters:
| Name | Type | Description | Default |
|---|
alpha | float | Smoothing parameter. | required |
alias | str | Custom name of the model. | ‘SES’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. | None |
SimpleExponentialSmoothing.fit
Fit the SimpleExponentialSmoothing model.
Fit an SimpleExponentialSmoothing to a time series (numpy array) y
and optionally exogenous variables (numpy array) X.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
X | array - like | Optional exogenous of shape (t, n_x). | None |
Returns:
| Name | Type | Description |
|---|
self | | SimpleExponentialSmoothing fitted model. |
SimpleExponentialSmoothing.predict
predict(h, X=None, level=None)
Predict with fitted SimpleExponentialSmoothing.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | array - like | Optional insample exogenous of shape (t, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
SimpleExponentialSmoothing.predict_in_sample
Access fitted SimpleExponentialSmoothing insample predictions.
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries fitted for point predictions. |
SimpleExponentialSmoothing.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient SimpleExponentialSmoothing predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (n, ). | required |
h | int | Forecast horizon. | required |
X | array - like | Optional insample exogenous of shape (t, n_x). | None |
X_future | array - like | Optional exogenous of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
fitted | bool | Whether or not to return insample predictions. | False |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
SimpleExponentialSmoothingOptimized
SimpleExponentialSmoothingOptimized
SimpleExponentialSmoothingOptimized(alias='SESOpt', prediction_intervals=None)
Bases: _TS
SimpleExponentialSmoothing model.
Uses a weighted average of all past observations where the weights decrease exponentially into the past.
Suitable for data with no clear trend or seasonality.
Assuming there are t observations, the one-step forecast is given by: hatyt+1=alphayt+(1−alpha)hatyt−1
The smoothing parameter alpha\* is optimized by square error minimization.
Parameters:
| Name | Type | Description | Default |
|---|
alias | str | Custom name of the model. | ‘SESOpt’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. This is required for generating future prediction intervals. | None |
SimpleExponentialSmoothingOptimized.fit
Fit the SimpleExponentialSmoothingOptimized model.
Fit an SimpleExponentialSmoothingOptimized to a time series (numpy array) y
and optionally exogenous variables (numpy array) X.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
X | array - like | Optional exogenous of shape (t, n_x). | None |
Returns:
| Name | Type | Description |
|---|
SimpleExponentialSmoothingOptimized | | SimpleExponentialSmoothingOptimized fitted model. |
SimpleExponentialSmoothingOptimized.predict
predict(h, X=None, level=None)
Predict with fitted SimpleExponentialSmoothingOptimized.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | array - like | Optional insample exogenous of shape (t, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
SimpleExponentialSmoothingOptimized.predict_in_sample
Access fitted SimpleExponentialSmoothingOptimized insample predictions.
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries fitted for point predictions. |
SimpleExponentialSmoothingOptimized.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient SimpleExponentialSmoothingOptimized predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (n, ). | required |
h | int | Forecast horizon. | required |
X | array - like | Optional insample exogenous of shape (t, n_x). | None |
X_future | array - like | Optional exogenous of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
fitted | bool | Whether or not to return insample predictions. | False |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
SeasonalExponentialSmoothing
SeasonalExponentialSmoothing
SeasonalExponentialSmoothing(season_length, alpha, alias='SeasonalES', prediction_intervals=None)
Bases: _TS
SeasonalExponentialSmoothing model.
Uses a weighted average of all past observations where the weights decrease exponentially into the past.
Suitable for data with no clear trend or seasonality.
Assuming there are t observations and season s, the one-step forecast is given by:
hatyt+1,s=alphayt+(1−alpha)hatyt−1,s
Parameters:
| Name | Type | Description | Default |
|---|
alpha | float | Smoothing parameter. | required |
season_length | int | Number of observations per unit of time. Ex: 24 Hourly data. | required |
alias | str | Custom name of the model. | ‘SeasonalES’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. This is required for generating future prediction intervals. | None |
SeasonalExponentialSmoothing.fit
Fit the SeasonalExponentialSmoothing model.
Fit an SeasonalExponentialSmoothing to a time series (numpy array) y
and optionally exogenous variables (numpy array) X.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
X | array - like | Optional exogenous of shape (t, n_x). | None |
Returns:
| Name | Type | Description |
|---|
SeasonalExponentialSmoothing | | SeasonalExponentialSmoothing fitted model. |
SeasonalExponentialSmoothing.predict
predict(h, X=None, level=None)
Predict with fitted SeasonalExponentialSmoothing.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | array - like | Optional insample exogenous of shape (t, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
SeasonalExponentialSmoothing.predict_in_sample
Access fitted SeasonalExponentialSmoothing insample predictions.
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries fitted for point predictions. |
SeasonalExponentialSmoothing.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient SeasonalExponentialSmoothing predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (n, ). | required |
h | int | Forecast horizon. | required |
X | array - like | Optional insample exogenous of shape (t, n_x). | None |
X_future | array - like | Optional exogenous of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
fitted | bool | Whether or not returns insample predictions. | False |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
SeasonalExponentialSmoothingOptimized
SeasonalExponentialSmoothingOptimized
SeasonalExponentialSmoothingOptimized(season_length, alias='SeasESOpt', prediction_intervals=None)
Bases: _TS
SeasonalExponentialSmoothingOptimized model.
Uses a weighted average of all past observations where the weights decrease exponentially into the past.
Suitable for data with no clear trend or seasonality.
Assuming there are t observations and season s, the one-step forecast is given by:
hatyt+1,s=alphayt+(1−alpha)hatyt−1,s
The smoothing parameter alpha\* is optimized by square error minimization.
Parameters:
| Name | Type | Description | Default |
|---|
season_length | int | Number of observations per unit of time. Ex: 24 Hourly data. | required |
alias | str | Custom name of the model. | ‘SeasESOpt’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. This is required for generating future prediction intervals. | None |
SeasonalExponentialSmoothingOptimized.fit
Fit the SeasonalExponentialSmoothingOptimized model.
Fit an SeasonalExponentialSmoothingOptimized to a time series (numpy array) y
and optionally exogenous variables (numpy array) X.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
X | array - like | Optional exogenous of shape (t, n_x). | None |
Returns:
| Name | Type | Description |
|---|
SeasonalExponentialSmoothingOptimized | | SeasonalExponentialSmoothingOptimized fitted model. |
SeasonalExponentialSmoothingOptimized.predict
predict(h, X=None, level=None)
Predict with fitted SeasonalExponentialSmoothingOptimized.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | array - like | Optional insample exogenous of shape (t, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
SeasonalExponentialSmoothingOptimized.predict_in_sample
Access fitted SeasonalExponentialSmoothingOptimized insample predictions.
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries fitted for point predictions. |
SeasonalExponentialSmoothingOptimized.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient SeasonalExponentialSmoothingOptimized predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (n, ). | required |
h | int | Forecast horizon. | required |
X | array - like | Optional insample exogenous of shape (t, n_x). | None |
X_future | array - like | Optional exogenous of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
fitted | bool | Whether or not to return insample predictions. | False |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
Holt
Holt
Holt(season_length=1, error_type='A', alias='Holt', prediction_intervals=None)
Bases: AutoETS
Holt’s method.
Also known as double exponential smoothing, Holt’s method is an extension of exponential smoothing for series with a trend.
This implementation returns the corresponding ETS model with additive (A) or multiplicative (M) errors (so either ‘AAN’ or ‘MAN’).
Parameters:
| Name | Type | Description | Default |
|---|
season_length | int | Number of observations per unit of time. Ex: 12 Monthly data. | 1 |
error_type | str | The type of error of the ETS model. Can be additive (A) or multiplicative (M). | ’A’ |
alias | str | Custom name of the model. | ‘Holt’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. | None |
HoltWinters
HoltWinters
HoltWinters(season_length=1, error_type='A', alias='HoltWinters', prediction_intervals=None)
Bases: AutoETS
Holt-Winters’ method.
Also known as triple exponential smoothing, Holt-Winters’ method is an extension of exponential smoothing for series that contain both trend and seasonality.
This implementation returns the corresponding ETS model with additive (A) or multiplicative (M) errors (so either ‘AAA’ or ‘MAM’).
Parameters:
| Name | Type | Description | Default |
|---|
season_length | int | Number of observations per unit of time. Ex: 12 Monthly data. | 1 |
error_type | str | The type of error of the ETS model. Can be additive (A) or multiplicative (M). | ’A’ |
alias | str | Custom name of the model. | ‘HoltWinters’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. | None |
Baseline Models
HistoricAverage
HistoricAverage
HistoricAverage(alias='HistoricAverage', prediction_intervals=None)
Bases: _TS
HistoricAverage model.
Also known as mean method. Uses a simple average of all past observations.
Assuming there are t observations, the one-step forecast is given by:
y^t+1=t1j=1∑tyj
Parameters:
| Name | Type | Description | Default |
|---|
alias | str | Custom name of the model. | ‘HistoricAverage’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. | None |
HistoricAverage.fit
Fit the HistoricAverage model.
Fit an HistoricAverage to a time series (numpy array) y.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
X | array - like | Optional exogenous of shape (t, n_x). | None |
Returns:
| Name | Type | Description |
|---|
self | | HistoricAverage fitted model. |
r
HistoricAverage.predict
predict(h, X=None, level=None)
Predict with fitted HistoricAverage.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | Optional[ndarray] | Optional exogenous of shape (h, n_x). Defaults to None. | None |
level | Optional[List[int]] | Confidence levels (0-100) for prediction intervals. Defaults to None. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
HistoricAverage.predict_in_sample
predict_in_sample(level=None)
Access fitted HistoricAverage insample predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | Optional[List[int]] | Confidence levels (0-100) for prediction intervals. Defaults to None. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries fitted for point predictions. |
HistoricAverage.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient HistoricAverage predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | ndarray | Clean time series of shape (n, ). | required |
h | int | Forecast horizon. | required |
X | Optional[ndarray] | Optional insample exogenous of shape (t, n_x). Defaults to None. | None |
X_future | Optional[ndarray] | Optional exogenous of shape (h, n_x). Defaults to None. | None |
level | Optional[List[int]] | Confidence levels (0-100) for prediction intervals. Defaults to None. | None |
fitted | bool | Whether or not to return insample predictions. Defaults to False. | False |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
Naive
Naive
Naive(alias='Naive', prediction_intervals=None)
Bases: _TS
Naive model.
All forecasts have the value of the last observation:
haty_t+1=yt for all t
Parameters:
| Name | Type | Description | Default |
|---|
alias | str | Custom name of the model. Defaults to “Naive”. | ’Naive’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. Defaults to None. | None |
Naive.fit
Fit the Naive model.
Fit an Naive to a time series (numpy.array) y.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
X | array - like | Optional exogenous of shape (t, n_x). | None |
Returns:
| Name | Type | Description |
|---|
self | | Naive fitted model. |
Naive.predict
predict(h, X=None, level=None)
Predict with fitted Naive.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | array - like | Optional exogenous of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
Naive.predict_in_sample
predict_in_sample(level=None)
Access fitted Naive insample predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries fitted for point predictions. |
Naive.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient Naive predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (n,). | required |
h | int | Forecast horizon. | required |
X | array - like | Optional insample exogenous of shape (t, n_x). | None |
X_future | array - like | Optional exogenous of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
fitted | bool | Whether or not to return insample predictions. | False |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
RandomWalkWithDrift
RandomWalkWithDrift
RandomWalkWithDrift(alias='RWD', prediction_intervals=None)
Bases: _TS
RandomWalkWithDrift model.
A variation of the naive method allows the forecasts to change over time.
The amout of change, called drift, is the average change seen in the historical data.
y^t+1=yt+t−11j=1∑t(yj−yj−1)=yt+t−1yt−y1
From the previous equation, we can see that this is equivalent to extrapolating a line between
the first and the last observation.
Parameters:
| Name | Type | Description | Default |
|---|
alias | str | Custom name of the model. | ‘RWD’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. | None |
RandomWalkWithDrift.fit
Fit the RandomWalkWithDrift model.
Fit an RandomWalkWithDrift to a time series (numpy array) y.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
Returns:
| Name | Type | Description |
|---|
self | | RandomWalkWithDrift fitted model. |
r
RandomWalkWithDrift.predict
predict(h, X=None, level=None)
Predict with fitted RandomWalkWithDrift.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | array - like | Optional exogenous of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
RandomWalkWithDrift.predict_in_sample
predict_in_sample(level=None)
Access fitted RandomWalkWithDrift insample predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries fitted for point predictions and level_* for probabilistic predictions. |
RandomWalkWithDrift.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient RandomWalkWithDrift predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (n,). | required |
h | int | Forecast horizon. | required |
X | array - like | Optional insample exogenous of shape (t, n_x). | None |
X_future | array - like | Optional exogenous of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
fitted | bool | Whether or not to return insample predictions. | False |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
SeasonalNaive
SeasonalNaive
SeasonalNaive(season_length, alias='SeasonalNaive', prediction_intervals=None)
Bases: _TS
Seasonal naive model.
A method similar to the naive, but uses the last known observation of the same period (e.g. the same month of the previous year) in order to capture seasonal variations.
Parameters:
| Name | Type | Description | Default |
|---|
season_length | int | Number of observations per unit of time. Ex: 24 Hourly data. | required |
alias | str | Custom name of the model. | ‘SeasonalNaive’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. | None |
SeasonalNaive.fit
Fit the SeasonalNaive model.
Fit an SeasonalNaive to a time series (numpy array) y.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
X | array - like | Optional exogenous of shape (t, n_x). | None |
Returns:
| Name | Type | Description |
|---|
self | | SeasonalNaive fitted model. |
r
SeasonalNaive.predict
predict(h, X=None, level=None)
Predict with fitted Naive.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | array - like | Optional exogenous of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
SeasonalNaive.predict_in_sample
predict_in_sample(level=None)
Access fitted SeasonalNaive insample predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries fitted for point predictions and level_* for probabilistic predictions. |
r
SeasonalNaive.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient SeasonalNaive predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (n, ). | required |
h | int | Forecast horizon. | required |
X | array - like | Optional insample exogenous of shape (t, n_x). | None |
X_future | array - like | Optional exogenous of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
fitted | bool | Whether or not to return insample predictions. | False |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
WindowAverage
WindowAverage
WindowAverage(window_size, alias='WindowAverage', prediction_intervals=None)
Bases: _TS
WindowAverage model.
Uses the average of the last k observations, with k the length of the window.
Wider windows will capture global trends, while narrow windows will reveal local trends.
The length of the window selected should take into account the importance of past
observations and how fast the series changes.
Parameters:
| Name | Type | Description | Default |
|---|
window_size | int | Size of truncated series on which average is estimated. | required |
alias | str | Custom name of the model. | ‘WindowAverage’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. This is required for generating future prediction intervals. | None |
r
WindowAverage.fit
Fit the WindowAverage model.
Fit an WindowAverage to a time series (numpy array) y
and optionally exogenous variables (numpy array) X.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
X | array - like | Optional exogenous of shape (t, n_x). | None |
Returns:
| Name | Type | Description |
|---|
self | | WindowAverage fitted model. |
WindowAverage.predict
predict(h, X=None, level=None)
Predict with fitted WindowAverage.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | array | Optional exogenous of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
WindowAverage.predict_in_sample
Access fitted WindowAverage insample predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | List[float] | Confidence levels (0-100) for prediction intervals. | required |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries fitted for point predictions and level_* for probabilistic predictions. |
WindowAverage.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient WindowAverage predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | ndarray | Clean time series of shape (n, ). | required |
h | int | Forecast horizon. | required |
X | Optional[ndarray] | Optional insample exogenous of shape (t, n_x). | None |
X_future | Optional[ndarray] | Optional exogenous of shape (h, n_x). | None |
level | Optional[List[int]] | Confidence levels (0-100) for prediction intervals. | None |
fitted | bool | Whether or not to return insample predictions. | False |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
SeasonalWindowAverage
SeasonalWindowAverage
SeasonalWindowAverage(season_length, window_size, alias='SeasWA', prediction_intervals=None)
Bases: _TS
SeasonalWindowAverage model.
An average of the last k observations of the same period, with k the length of the window.
Parameters:
| Name | Type | Description | Default |
|---|
season_length | int | Number of observations per unit of time. Ex: 24 Hourly data. | required |
window_size | int | Size of truncated series on which average is estimated. | required |
alias | str | Custom name of the model. | ‘SeasWA’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. This is required for generating future prediction intervals. | None |
r
SeasonalWindowAverage.fit
Fit the SeasonalWindowAverage model.
Fit an SeasonalWindowAverage to a time series (numpy array) y
and optionally exogenous variables (numpy array) X.
Parameters:
| Name | Type | Description | Default |
|---|
y | ndarray | Clean time series of shape (t, ). | required |
X | Optional[ndarray] | Optional exogenous of shape (t, n_x). | None |
Returns:
| Name | Type | Description |
|---|
SeasonalWindowAverage | | SeasonalWindowAverage fitted model. |
SeasonalWindowAverage.predict
predict(h, X=None, level=None)
Predict with fitted SeasonalWindowAverage.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | Optional[ndarray] | Optional insample exogenous of shape (t, n_x). | None |
level | Optional[List[int]] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
SeasonalWindowAverage.predict_in_sample
Access fitted SeasonalWindowAverage insample predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | Optional[List[int]] | Confidence levels (0-100) for prediction intervals. | required |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries fitted for point predictions and level_* for probabilistic predictions. |
SeasonalWindowAverage.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient SeasonalWindowAverage predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | ndarray | Clean time series of shape (n,). | required |
h | int | Forecast horizon. | required |
X | Optional[ndarray] | Optional insample exogenous of shape (t, n_x). Defaults to None. | None |
X_future | Optional[ndarray] | Optional exogenous of shape (h, n_x). Defaults to None. | None |
level | Optional[List[int]] | Confidence levels for prediction intervals. Defaults to None. | None |
fitted | bool | Whether or not to return insample predictions. Defaults to False. | False |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
Sparse or Intermittent Models
ADIDA
ADIDA
ADIDA(alias='ADIDA', prediction_intervals=None)
Bases: _TS
ADIDA model.
Aggregate-Dissagregate Intermittent Demand Approach: Uses temporal aggregation to reduce the
number of zero observations. Once the data has been agregated, it uses the optimized SES to
generate the forecasts at the new level. It then breaks down the forecast to the original
level using equal weights.
ADIDA specializes on sparse or intermittent series are series with very few non-zero observations.
They are notoriously hard to forecast, and so, different methods have been developed
especifically for them.
Parameters:
| Name | Type | Description | Default |
|---|
alias | str | Custom name of the model. Defaults to “ADIDA”. | ’ADIDA’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. Defaults to None. | None |
ADIDA.fit
Fit the ADIDA model.
Fit an ADIDA to a time series (numpy array) y.
Parameters:
| Name | Type | Description | Default |
|---|
y | ndarray | Clean time series of shape (t, ). | required |
X | Optional[ndarray] | Optional exogenous variables. Defaults to None. | None |
Returns:
| Name | Type | Description |
|---|
ADIDA | | ADIDA fitted model. |
ADIDA.predict
predict(h, X=None, level=None)
Predict with fitted ADIDA.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | Optional[ndarray] | Optional exogenous of shape (h, n_x). Defaults to None. | None |
level | Optional[List[int]] | Confidence levels (0-100) for prediction intervals. Defaults to None. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
ADIDA.predict_in_sample
predict_in_sample(level=None)
Access fitted ADIDA insample predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | Optional[List[int]] | Confidence levels (0-100) for prediction intervals. Defaults to None. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries fitted for point predictions and level_* for probabilistic predictions. |
ADIDA.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient ADIDA predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | ndarray | Clean time series of shape (n,). | required |
h | int | Forecast horizon. | required |
X | Optional[ndarray] | Optional insample exogenous of shape (t, n_x). Defaults to None. | None |
X_future | Optional[ndarray] | Optional exogenous of shape (h, n_x). Defaults to None. | None |
level | Optional[List[int]] | Confidence levels (0-100) for prediction intervals. Defaults to None. | None |
fitted | bool | Whether or not to return insample predictions. Defaults to False. | False |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
CrostonClassic
CrostonClassic
CrostonClassic(alias='CrostonClassic', prediction_intervals=None)
Bases: _TS
CrostonClassic model.
A method to forecast time series that exhibit intermittent demand.
It decomposes the original time series into a non-zero demand size zt and
inter-demand intervals pt. Then the forecast is given by:
y^t=p^tz^t
where hatz_t and hatp_t are forecasted using SES. The smoothing parameter
of both components is set equal to 0.1
Parameters:
| Name | Type | Description | Default |
|---|
alias | str | Custom name of the model. Defaults to “CrostonClassic”. | ’CrostonClassic’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. Defaults to None. | None |
CrostonClassic.fit
Fit the CrostonClassic model.
Fit an CrostonClassic to a time series (numpy array) y.
Parameters:
| Name | Type | Description | Default |
|---|
y | ndarray | Clean time series of shape (t, ). | required |
X | Optional[ndarray] | Optional exogenous variables. Defaults to None. | None |
Returns:
| Name | Type | Description |
|---|
CrostonClassic | | CrostonClassic fitted model. |
CrostonClassic.predict
predict(h, X=None, level=None)
Predict with fitted CrostonClassic.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | Optional[ndarray] | Optional exogenous of shape (h, n_x). Defaults to None. | None |
level | Optional[List[int]] | Confidence levels (0-100) for prediction intervals. Defaults to None. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
CrostonClassic.predict_in_sample
predict_in_sample(level=None)
Access fitted CrostonClassic insample predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | Optional[List[int]] | Confidence levels (0-100) for prediction intervals. Defaults to None. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries fitted for point predictions and level_* for probabilistic predictions. |
CrostonClassic.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient CrostonClassic predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | ndarray | Clean time series of shape (n, ). | required |
h | int | Forecast horizon. | required |
X | Optional[ndarray] | Optional insample exogenous of shape (t, n_x). Defaults to None. | None |
X_future | Optional[ndarray] | Optional exogenous of shape (h, n_x). Defaults to None. | None |
level | Optional[List[int]] | Confidence levels (0-100) for prediction intervals. Defaults to None. | None |
fitted | bool | Whether or not returns insample predictions. Defaults to False. | False |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
CrostonOptimized
CrostonOptimized
CrostonOptimized(alias='CrostonOptimized', prediction_intervals=None)
Bases: _TS
CrostonOptimized model.
A method to forecast time series that exhibit intermittent demand.
It decomposes the original time series into a non-zero demand size zt and
inter-demand intervals pt. Then the forecast is given by:
y^t=p^tz^t
A variation of the classic Croston’s method where the smooting paramater is optimally
selected from the range [0.1,0.3]. Both the non-zero demand zt and the inter-demand
intervals pt are smoothed separately, so their smoothing parameters can be different.
Parameters:
| Name | Type | Description | Default |
|---|
alias | str | Custom name of the model. Defaults to “CrostonOptimized”. | ’CrostonOptimized’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. This is required for generating future prediction intervals. Defaults to None. | None |
CrostonOptimized.fit
Fit the CrostonOptimized model.
Fit an CrostonOptimized to a time series (numpy array) y.
Parameters:
| Name | Type | Description | Default |
|---|
y | ndarray | Clean time series of shape (t, ). | required |
X | Optional[ndarray] | Optional exogenous variables. Defaults to None. | None |
Returns:
| Name | Type | Description |
|---|
CrostonOptimized | | CrostonOptimized fitted model. |
CrostonOptimized.predict
predict(h, X=None, level=None)
Predict with fitted CrostonOptimized.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | Optional[ndarray] | Optional insample exogenous of shape (t, n_x). Defaults to None. | None |
level | Optional[List[int]] | Confidence levels (0-100) for prediction intervals. Defaults to None. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
CrostonOptimized.predict_in_sample
predict_in_sample(level=None)
Access fitted CrostonOptimized insample predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | Optional[List[int]] | Confidence levels (0-100) for prediction intervals. Defaults to None. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries fitted for point predictions and level_* for probabilistic predictions. |
CrostonOptimized.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient CrostonOptimized predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | ndarray | Clean time series of shape (n, ). | required |
h | int | Forecast horizon. | required |
X | Optional[ndarray] | Optional insample exogenous of shape (t, n_x). Defaults to None. | None |
X_future | Optional[ndarray] | Optional exogenous of shape (h, n_x). Defaults to None. | None |
level | Optional[List[int]] | Confidence levels (0-100) for prediction intervals. Defaults to None. | None |
fitted | bool | Whether or not returns insample predictions. Defaults to False. | False |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
CrostonSBA
CrostonSBA
CrostonSBA(alias='CrostonSBA', prediction_intervals=None)
Bases: _TS
CrostonSBA model.
A method to forecast time series that exhibit intermittent demand.
It decomposes the original time series into a non-zero demand size zt and
inter-demand intervals pt. Then the forecast is given by:
y^t=p^tz^t
A variation of the classic Croston’s method that uses a debiasing factor, so that the
forecast is given by:
y^t=0.95p^tz^t
Parameters:
| Name | Type | Description | Default |
|---|
alias | str | Custom name of the model. Defaults to “CrostonSBA”. | ’CrostonSBA’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. Defaults to None. | None |
CrostonSBA.fit
Fit the CrostonSBA model.
Fit an CrostonSBA to a time series (numpy array) y.
Parameters:
| Name | Type | Description | Default |
|---|
y | ndarray | Clean time series of shape (t, ). | required |
X | Optional[ndarray] | Optional exogenous variables. Defaults to None. | None |
Returns:
| Name | Type | Description |
|---|
CrostonSBA | | CrostonSBA fitted model. |
CrostonSBA.predict
predict(h, X=None, level=None)
Predict with fitted CrostonSBA.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | Optional[ndarray] | Optional exogenous of shape (h, n_x). Defaults to None. | None |
level | Optional[List[int]] | Confidence levels (0-100) for prediction intervals. Defaults to None. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
CrostonSBA.predict_in_sample
predict_in_sample(level=None)
Access fitted CrostonSBA insample predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | Optional[List[int]] | Confidence levels (0-100) prediction intervals. Defaults to None. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries fitted for point predictions and level_* for probabilistic predictions. |
CrostonSBA.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient CrostonSBA predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | ndarray | Clean time series of shape (n, ). | required |
h | int | Forecast horizon. | required |
X | Optional[ndarray] | Optional insample exogenous of shape (t, n_x). Defaults to None. | None |
X_future | Optional[ndarray] | Optional exogenous of shape (h, n_x). Defaults to None. | None |
level | Optional[List[int]] | Confidence levels (0-100) for prediction intervals. Defaults to None. | None |
fitted | bool | Whether or not to return insample predictions. Defaults to False. | False |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
IMAPA
IMAPA
IMAPA(alias='IMAPA', prediction_intervals=None)
Bases: _TS
IMAPA model.
Intermittent Multiple Aggregation Prediction Algorithm: Similar to ADIDA, but instead of
using a single aggregation level, it considers multiple in order to capture different
dynamics of the data. Uses the optimized SES to generate the forecasts at the new levels
and then combines them using a simple average.
Parameters:
| Name | Type | Description | Default |
|---|
alias | str | Custom name of the model. Defaults to “IMAPA”. | ’IMAPA’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. Defaults to None. | None |
IMAPA.fit
Fit the IMAPA model.
Fit an IMAPA to a time series (numpy array) y.
Parameters:
| Name | Type | Description | Default |
|---|
y | ndarray | Clean time series of shape (t, ). | required |
X | Optional[ndarray] | Optional exogenous variables. Defaults to None. | None |
Returns:
| Name | Type | Description |
|---|
IMAPA | | IMAPA fitted model. |
IMAPA.predict
predict(h, X=None, level=None)
Predict with fitted IMAPA.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | Optional[ndarray] | Optional exogenous of shape (h, n_x). Defaults to None. | None |
level | Optional[List[int]] | Confidence levels (0-100) for prediction intervals. Defaults to None. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
IMAPA.predict_in_sample
predict_in_sample(level=None)
Access fitted IMAPA insample predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | Optional[List[int]] | Confidence levels (0-100) for prediction intervals. Defaults to None. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries fitted for point predictions and level_* for probabilistic predictions. |
IMAPA.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient IMAPA predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | ndarray | Clean time series of shape (n, ). | required |
h | int | Forecast horizon. | required |
X | Optional[ndarray] | Optional insample exogenous of shape (t, n_x). Defaults to None. | None |
X_future | Optional[ndarray] | Optional exogenous of shape (h, n_x). Defaults to None. | None |
level | Optional[List[int]] | Confidence levels (0-100) for prediction intervals. Defaults to None. | None |
fitted | bool | Whether or not to return insample predictions. Defaults to False. | False |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
TSB
TSB
TSB(alpha_d, alpha_p, alias='TSB', prediction_intervals=None)
Bases: _TS
TSB model.
Teunter-Syntetos-Babai: A modification of Croston’s method that replaces the inter-demand
intervals with the demand probability dt, which is defined as follows.
dt={10if demand occurs at time totherwise.
Hence, the forecast is given by
y^t=d^tzt^
Both dt and zt are forecasted using SES. The smooting paramaters of each may differ,
like in the optimized Croston’s method.
Parameters:
| Name | Type | Description | Default |
|---|
alpha_d | float | Smoothing parameter for demand. | required |
alpha_p | float | Smoothing parameter for probability. | required |
alias | str | Custom name of the model. Defaults to “TSB”. | ’TSB’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. This is required for generating future prediction intervals. Defaults to None. | None |
TSB.fit
Fit the TSB model.
Fit an TSB to a time series (numpy array) y.
Parameters:
| Name | Type | Description | Default |
|---|
y | ndarray | Clean time series of shape (t, ). | required |
X | Optional[ndarray] | Optional exogenous variables. Defaults to None. | None |
Returns:
| Name | Type | Description |
|---|
TSB | | TSB fitted model. |
TSB.predict
predict(h, X=None, level=None)
Predict with fitted TSB.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | Optional[ndarray] | Optional exogenous of shape (h, n_x). Defaults to None. | None |
level | Optional[List[int]] | Confidence levels (0-100) for prediction intervals. Defaults to None. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
TSB.predict_in_sample
predict_in_sample(level=None)
Access fitted TSB insample predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
forecasts | dict | Dictionary with entries fitted for point predictions and level_* for probabilistic predictions. |
TSB.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient TSB predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (n, ). | required |
h | int | Forecast horizon. | required |
X | array - like | Optional insample exogenous of shape (t, n_x). | None |
X_future | array - like | Optional exogenous of shape (h, n_x). | None |
fitted | bool | Whether or not returns insample predictions. | False |
Returns:
| Name | Type | Description |
|---|
forecasts | dict | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
Multiple Seasonalities
MSTL
MSTL
MSTL(season_length, trend_forecaster=AutoETS(model='ZZN'), stl_kwargs=None, alias='MSTL', prediction_intervals=None)
Bases: _TS
MSTL model.
The MSTL (Multiple Seasonal-Trend decomposition using LOESS) decomposes the time series
in multiple seasonalities using LOESS. Then forecasts the trend using
a custom non-seaonal model and each seasonality using a SeasonalNaive model.
Parameters:
| Name | Type | Description | Default |
|---|
season_length | Union[int, List[int]] | Number of observations per unit of time. For multiple seasonalities use a list. | required |
trend_forecaster | model, default=AutoETS(model=‘ZZN’) | StatsForecast model used to forecast the trend component. | AutoETS(model=‘ZZN’) |
stl_kwargs | dict | Extra arguments to pass to statsmodels.tsa.seasonal.STL. The period and seasonal arguments are reserved. | None |
alias | str | Custom name of the model. | ‘MSTL’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. | None |
MSTL.fit
Fit the MSTL model.
Fit MSTL to a time series (numpy array) y.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
X | array - like | Optional exogenous of shape (t, n_x). | None |
Returns:
| Name | Type | Description |
|---|
self | | MSTL fitted model. |
MSTL.predict
predict(h, X=None, level=None)
Predict with fitted MSTL.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | array - like | Optional exogenous of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
forecasts | dict | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
MSTL.predict_in_sample
predict_in_sample(level=None)
Access fitted MSTL insample predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
forecasts | dict | Dictionary with entries fitted for point predictions and level_* for probabilistic predictions. |
MSTL.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient MSTL predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (n, ). | required |
h | int | Forecast horizon. | required |
X | array - like | Optional insample exogenous of shape (t, n_x). | None |
X_future | array - like | Optional exogenous of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
fitted | bool | Whether or not to return insample predictions. | False |
Returns:
| Name | Type | Description |
|---|
forecasts | dict | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
MFLES
MFLES
MFLES(season_length=None, fourier_order=None, max_rounds=50, ma=None, alpha=1.0, decay=-1.0, changepoints=True, n_changepoints=0.25, seasonal_lr=0.9, trend_lr=0.9, exogenous_lr=1.0, residuals_lr=1.0, cov_threshold=0.7, moving_medians=False, min_alpha=0.05, max_alpha=1.0, trend_penalty=True, multiplicative=None, smoother=False, robust=None, verbose=False, prediction_intervals=None, alias='MFLES')
Bases: _TS
MFLES model.
A method to forecast time series based on Gradient Boosted Time Series Decomposition
which treats traditional decomposition as the base estimator in the boosting
process. Unlike normal gradient boosting, slight learning rates are applied at the
component level (trend/seasonality/exogenous).
The method derives its name from some of the underlying estimators that can
enter into the boosting procedure, specifically: a simple Median, Fourier
functions for seasonality, a simple/piecewise Linear trend, and Exponential
Smoothing.
Parameters:
| Name | Type | Description | Default |
|---|
season_length | int or list of int | Number of observations per unit of time. Ex: 24 Hourly data. Default None. | None |
fourier_order | int | How many fourier sin/cos pairs to create, the larger the number the more complex of a seasonal pattern can be fitted. A lower number leads to smoother results. This is auto-set based on seasonal_period. Default None. | None |
max_rounds | int | The max number of boosting rounds. The boosting will auto-stop but depending on other parameters such as rs_lr you may want more rounds. Generally more rounds means a smoother fit. Default 50. | 50 |
ma | int | The moving average order to use, this is auto-set based on internal logic. Passing 4 would fit a 4 period moving average on the residual component. Default None. | None |
alpha | float | The alpha which is used in fitting the underlying LASSO when using piecewise functions. Default 1.0. | 1.0 |
decay | float | Effects the slopes of the piecewise-linear basis function. Default -1.0. | -1.0 |
changepoints | boolean | Whether to fit for changepoints if all other logic allows for it. If False, MFLES will not ever fit a piecewise trend. Default True. | True |
n_changepoints | int or float | Number (if int) or proportion (if float) of changepoint knots to place. The default of 0.25 will place 0.25 * (series length) number of knots. Default 0.25. | 0.25 |
seasonal_lr | float | A shrinkage parameter (0 < seasonal_lr <= 1) which penalizes the seasonal fit. A value of 0.9 will flatly multiply the seasonal fit by 0.9 each boosting round, this can be used to allow more signal to the exogenous component. Default 0.9. | 0.9 |
trend_lr | float | A shrinkage parameter (0 < trend_lr <= 1) which penalizes the linear trend fit A value of 0.9 will flatly multiply the linear fit by 0.9 each boosting round, this can be used to allow more signal to the seasonality or exogenous components. Default 0.9. | 0.9 |
exogenous_lr | float | The shrinkage parameter (0 < exogenous_lr <= 1) which controls how much of the exogenous signal is carried to the next round. Default 1.0. | 1.0 |
residuals_lr | float | A shrinkage parameter (0 < residuals_lr <= 1) which penalizes the residual smoothing. A value of 0.9 will flatly multiply the residual fit by 0.9 each boosting round, this can be used to allow more signal to the seasonality or linear components. Default 1.0. | 1.0 |
cov_threshold | float | The deseasonalized cov is used to auto-set some logic, lowering the cov_threshold will result in simpler and less complex residual smoothing. If you pass something like 1000 then there will be no safeguards applied. Default 0.7. | 0.7 |
moving_medians | bool | The default behavior is to fit an initial median to the time series. If True, then it will fit a median per seasonal period. Default False. | False |
min_alpha | float | The minimum alpha in the SES ensemble. Default 0.05. | 0.05 |
max_alpha | float | The maximum alpha used in the SES ensemble. Default 1.0. | 1.0 |
trend_penalty | bool | Whether to apply a simple penalty to the linear trend component, very useful for dealing with the potentially dangerous piecewise trend. Default True. | True |
multiplicative | bool | Auto-set based on internal logic. If True, it will simply take the log of the time series. Default None. | None |
smoother | bool | If True, then a simple exponential ensemble will be used rather than auto settings. Default False. | False |
robust | bool | If True then MFLES will fit using more reserved methods, i.e. not using piecewise trend or moving average residual smoother. Auto-set based on internal logic. Default None. | None |
verbose | bool | Print debugging information. Default False. | False |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. This is required for generating future prediction intervals. | None |
alias | str | Custom name of the model. Default ‘MFLES’. | ‘MFLES’ |
MFLES.fit
Fit the model
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
X | array - like | Exogenous of shape (t, n_x). Default None. | None |
Returns:
| Name | Type | Description |
|---|
self | MFLES | Fitted MFLES object. |
MFLES.predict
predict(h, X=None, level=None)
Predict with fitted MFLES.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | array - like | Exogenous of shape (h, n_x). Default None. | None |
level | List[int] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
forecasts | dict | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
MFLES.predict_in_sample
predict_in_sample(level=None)
Access fitted SklearnModel insample predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | List[int] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
forecasts | dict | Dictionary with entries fitted for point predictions and level_* for probabilistic predictions. |
MFLES.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient MFLES predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
h | int | Forecast horizon. | required |
X | array - like | Insample exogenous of shape (t, n_x). | None |
X_future | array - like | Exogenous of shape (h, n_x). | None |
level | List[int] | Confidence levels (0-100) for prediction intervals. | None |
fitted | bool | Whether or not to return insample predictions. Default False. | False |
Returns:
| Name | Type | Description |
|---|
forecasts | dict | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
TBATS
TBATS
TBATS(season_length, use_boxcox=True, bc_lower_bound=0.0, bc_upper_bound=1.0, use_trend=True, use_damped_trend=False, use_arma_errors=False, alias='TBATS')
Bases: AutoTBATS
Trigonometric Box-Cox transform, ARMA errors, Trend and Seasonal components (TBATS) model.
TBATS is an innovations state space model framework used for forecasting time series with multiple seasonalities. It uses a Box-Cox tranformation, ARMA errors, and a trigonometric representation of the seasonal patterns based on Fourier series.
The name TBATS is an acronym for the key features of the model: Trigonometric, Box-Cox transform, ARMA errors, Trend, and Seasonal components.
Parameters:
| Name | Type | Description | Default |
|---|
season_length | Union[int, List[int]] | Number of observations per unit of time. Ex: 24 Hourly data. | required |
use_boxcox | Optional[bool] | Whether or not to use a Box-Cox transformation. Default True. | True |
bc_lower_bound | float | Lower bound for the Box-Cox transformation. Default 0.0. | 0.0 |
bc_upper_bound | float | Upper bound for the Box-Cox transformation. Default 1.0. | 1.0 |
use_trend | Optional[bool] | Whether or not to use a trend component. Default True. | True |
use_damped_trend | Optional[bool] | Whether or not to dampen the trend component. Default False. | False |
use_arma_errors | bool | Whether or not to use a ARMA errors. Default False. | False |
alias | str | Custom name of the model. Default ‘TBATS’. | ‘TBATS’ |
Theta Family
Theta
Theta
Theta(season_length=1, decomposition_type='multiplicative', alias='Theta', prediction_intervals=None)
Bases: AutoTheta
Standard Theta Method.
Parameters:
| Name | Type | Description | Default |
|---|
season_length | int | Number of observations per unit of time. Ex: 24 Hourly data. Default 1. | 1 |
decomposition_type | str | Sesonal decomposition type, ‘multiplicative’ (default) or ‘additive’. Default ‘multiplicative’. | ‘multiplicative’ |
alias | str | Custom name of the model. Default ‘Theta’. | ‘Theta’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. Default None. | None |
OptimizedTheta
OptimizedTheta
OptimizedTheta(season_length=1, decomposition_type='multiplicative', alias='OptimizedTheta', prediction_intervals=None)
Bases: AutoTheta
Optimized Theta Method.
Parameters:
| Name | Type | Description | Default |
|---|
season_length | int | Number of observations per unit of time. Ex: 24 Hourly data. Default 1. | 1 |
decomposition_type | str | Sesonal decomposition type, ‘multiplicative’ (default) or ‘additive’. Default ‘multiplicative’. | ‘multiplicative’ |
alias | str | Custom name of the model. Default ‘OptimizedTheta’. | ‘OptimizedTheta’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. Default None. | None |
DynamicTheta
DynamicTheta
DynamicTheta(season_length=1, decomposition_type='multiplicative', alias='DynamicTheta', prediction_intervals=None)
Bases: AutoTheta
Dynamic Standard Theta Method.
Parameters:
| Name | Type | Description | Default |
|---|
season_length | int | Number of observations per unit of time. Ex: 24 Hourly data. | 1 |
decomposition_type | str | Sesonal decomposition type, ‘multiplicative’ (default) or ‘additive’. | ‘multiplicative’ |
alias | str | Custom name of the model. | ‘DynamicTheta’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. | None |
DynamicOptimizedTheta
DynamicOptimizedTheta
DynamicOptimizedTheta(season_length=1, decomposition_type='multiplicative', alias='DynamicOptimizedTheta', prediction_intervals=None)
Bases: AutoTheta
Dynamic Optimized Theta Method.
Parameters:
| Name | Type | Description | Default |
|---|
season_length | int | Number of observations per unit of time. Ex: 24 Hourly data. | 1 |
decomposition_type | str | Sesonal decomposition type, ‘multiplicative’ (default) or ‘additive’. | ‘multiplicative’ |
alias | str | Custom name of the model. | ‘DynamicOptimizedTheta’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. | None |
ARCH/GARCH Family
GARCH
GARCH
GARCH(p=1, q=1, alias='GARCH', prediction_intervals=None)
Bases: _TS
Generalized Autoregressive Conditional Heteroskedasticity (GARCH) model.
A method for modeling time series that exhibit non-constant volatility over time.
The GARCH model assumes that at time t, yt is given by:
yt=vtσt
with
σt2=w+i=1∑paiyt−i2+j=1∑qbjσt−j2.
Here vt is a sequence of iid random variables with zero mean and unit variance.
The coefficients w, ai, i=1,...,p, and bj, j=1,...,q must satisfy the following conditions:
-
w>0 and ai,bjgeq0 for all i and j.
-
sum_k=1max(p,q)ak+bk<1. Here it is assumed that ai=0 for i>p and bj=0 for j>q.
The ARCH model is a particular case of the GARCH model when q=0.
Parameters:
| Name | Type | Description | Default |
|---|
p | int | Number of lagged versions of the series. | 1 |
q | int | Number of lagged versions of the volatility. | 1 |
alias | str | Custom name of the model. | ‘GARCH’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. | None |
GARCH.fit
Fit GARCH model.
Fit GARCH model to a time series (numpy array) y.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
Returns:
| Name | Type | Description |
|---|
self | | GARCH model. |
GARCH.predict
predict(h, X=None, level=None)
Predict with fitted GARCH model.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | array - like | Optional exogenous of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
GARCH.predict_in_sample
predict_in_sample(level=None)
Access fitted GARCH model predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
forecasts | dict | Dictionary with entries fitted for point predictions and level_* for probabilistic predictions. |
GARCH.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient GARCH model.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (n, ). | required |
h | int | Forecast horizon. | required |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
fitted | bool | Whether or not returns insample predictions. | False |
Returns:
| Name | Type | Description |
|---|
forecasts | dict | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
ARCH
ARCH
ARCH(p=1, alias='ARCH', prediction_intervals=None)
Bases: GARCH
Autoregressive Conditional Heteroskedasticity (ARCH) model.
A particular case of the GARCH(p,q) model where q=0.
It assumes that at time t, yt is given by:
yt=ϵtσt
with
σt2=w0+i=1∑paiyt−i2
Here epsilont is a sequence of iid random variables with zero mean and unit variance.
The coefficients w and ai, i=1,...,p must be nonnegative and sum_k=1pak<1.
Parameters:
| Name | Type | Description | Default |
|---|
p | int | Number of lagged versions of the series. | 1 |
alias | str | Custom name of the model. | ‘ARCH’ |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. By default, the model will compute the native prediction intervals. | None |
Machine Learning
SklearnModel
SklearnModel
SklearnModel(model, prediction_intervals=None, alias=None)
Bases: _TS
scikit-learn model wrapper
Parameters:
| Name | Type | Description | Default |
|---|
model | BaseEstimator | scikit-learn estimator | required |
prediction_intervals | Optional[ConformalIntervals] | Information to compute conformal prediction intervals. This is required for generating future prediction intervals. | None |
alias | str | Custom name of the model. If None will use the model’s class. | None |
SklearnModel.fit
Fit the model.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
X | array - like | Exogenous of shape (t, n_x). | required |
Returns:
| Name | Type | Description |
|---|
SklearnModel | SklearnModel | Fitted SklearnModel object. |
SklearnModel.predict
predict(h, X, level=None)
Predict with fitted SklearnModel.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | array - like | Exogenous of shape (h, n_x). | required |
level | List[int] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | Dict[str, Any] | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
SklearnModel.predict_in_sample
predict_in_sample(level=None)
Access fitted SklearnModel insample predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | List[int] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | Dict[str, Any] | Dictionary with entries fitted for point predictions and level_* for probabilistic predictions. |
SklearnModel.forecast
forecast(y, h, X, X_future, level=None, fitted=False)
Memory Efficient SklearnModel predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
h | int | Forecast horizon. | required |
X | array - like | Insample exogenous of shape (t, n_x). | required |
X_future | array - like | Exogenous of shape (h, n_x). | required |
level | List[int] | Confidence levels (0-100) for prediction intervals. | None |
fitted | bool | Whether or not to return insample predictions. | False |
Returns:
| Name | Type | Description |
|---|
dict | Dict[str, Any] | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
Fallback Models
These models are used as fallbacks when other models fail during forecasting.
ConstantModel
ConstantModel
ConstantModel(constant, alias='ConstantModel')
Bases: _TS
Constant Model.
Returns Constant values.
Parameters:
| Name | Type | Description | Default |
|---|
constant | float | Custom value to return as forecast. | required |
alias | str | Custom name of the model. | ‘ConstantModel’ |
ConstantModel.fit
Fit the Constant model.
Fit an Constant Model to a time series (numpy.array) y.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (t, ). | required |
X | array - like | Optional exogenous of shape (t, n_x). | None |
Returns:
| Name | Type | Description |
|---|
ConstantModel | | Constant fitted model. |
ConstantModel.predict
predict(h, X=None, level=None)
Predict with fitted ConstantModel.
Parameters:
| Name | Type | Description | Default |
|---|
h | int | Forecast horizon. | required |
X | array - like | Optional exogenous of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
ConstantModel.predict_in_sample
predict_in_sample(level=None)
Access fitted Constant Model insample predictions.
Parameters:
| Name | Type | Description | Default |
|---|
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries fitted for point predictions and level_* for probabilistic predictions. |
ConstantModel.forecast
forecast(y, h, X=None, X_future=None, level=None, fitted=False)
Memory Efficient Constant Model predictions.
This method avoids memory burden due from object storage.
It is analogous to fit_predict without storing information.
It assumes you know the forecast horizon in advance.
Parameters:
| Name | Type | Description | Default |
|---|
y | array | Clean time series of shape (n,). | required |
h | int | Forecast horizon. | required |
X | array - like | Optional insample exogenous of shape (t, n_x). | None |
X_future | array - like | Optional exogenous of shape (h, n_x). | None |
level | List[float] | Confidence levels (0-100) for prediction intervals. | None |
fitted | bool | Whether or not to return insample predictions. | False |
Returns:
| Name | Type | Description |
|---|
dict | | Dictionary with entries mean for point predictions and level_* for probabilistic predictions. |
ZeroModel
ZeroModel
ZeroModel(alias='ZeroModel')
Bases: ConstantModel
Returns Zero forecasts.
Returns Zero values.
Parameters:
| Name | Type | Description | Default |
|---|
alias | str | Custom name of the model. | ‘ZeroModel’ |
NaNModel
NaNModel
NaNModel(alias='NaNModel')
Bases: ConstantModel
NaN Model.
Returns NaN values.
Parameters:
| Name | Type | Description | Default |
|---|
alias | str | Custom name of the model. | ‘NaNModel’ |
Usage Examples
Basic Model Usage
from statsforecast import StatsForecast
from statsforecast.models import AutoARIMA, Naive
from statsforecast.utils import generate_series
# Generate example data
df = generate_series(n_series=10)
# Create StatsForecast instance with models
sf = StatsForecast(
models=[
AutoARIMA(season_length=7),
Naive()
],
freq='D'
)
# Forecast
forecasts = sf.forecast(df=df, h=7)
Using Multiple Models
from statsforecast import StatsForecast
from statsforecast.models import (
AutoARIMA,
AutoETS,
SeasonalNaive,
Theta,
HistoricAverage
)
# Combine multiple models for comparison
models = [
AutoARIMA(season_length=12),
AutoETS(season_length=12),
SeasonalNaive(season_length=12),
Theta(season_length=12),
HistoricAverage()
]
sf = StatsForecast(models=models, freq='M', n_jobs=-1)
forecasts = sf.forecast(df=df, h=12, level=[80, 95])
Model with Prediction Intervals
from statsforecast import StatsForecast
from statsforecast.models import AutoARIMA
from statsforecast.utils import ConformalIntervals
# Create model with conformal prediction intervals
model = AutoARIMA(
season_length=12,
prediction_intervals=ConformalIntervals(n_windows=2, h=12),
alias='ConformalAutoARIMA'
)
sf = StatsForecast(models=[model], freq='M')
forecasts = sf.forecast(df=df, h=12, level=[80, 95])
Sparse/Intermittent Data
from statsforecast import StatsForecast
from statsforecast.models import (
CrostonOptimized,
ADIDA,
IMAPA,
TSB
)
# Models specialized for sparse/intermittent data
sparse_models = [
CrostonOptimized(),
ADIDA(),
IMAPA(),
TSB(alpha_d=0.2, alpha_p=0.2)
]
sf = StatsForecast(models=sparse_models, freq='D')
forecasts = sf.forecast(df=sparse_df, h=30)
Multiple Seasonalities
from statsforecast import StatsForecast
from statsforecast.models import MSTL, AutoTBATS
# For data with multiple seasonal patterns
models = [
MSTL(season_length=[24, 168]), # Hourly with daily and weekly seasonality
AutoTBATS(season_length=[24, 168])
]
sf = StatsForecast(models=models, freq='H')
forecasts = sf.forecast(df=hourly_df, h=168)
ARCH/GARCH for Volatility
from statsforecast import StatsForecast
from statsforecast.models import GARCH, ARCH
# Models for financial data with volatility
volatility_models = [
GARCH(p=1, q=1),
ARCH(p=1)
]
sf = StatsForecast(models=volatility_models, freq='D')
forecasts = sf.forecast(df=financial_df, h=30)
Using Scikit-learn Models
from statsforecast import StatsForecast
from statsforecast.models import SklearnModel
from sklearn.ensemble import RandomForestRegressor
from sklearn.linear_model import Ridge
# Wrap scikit-learn models
models = [
SklearnModel(RandomForestRegressor(n_estimators=100), alias='RF'),
SklearnModel(Ridge(alpha=1.0), alias='Ridge')
]
sf = StatsForecast(models=models, freq='D')
forecasts = sf.forecast(df=df, h=14)
Model Selection Tips
- For automatic selection: Start with
AutoARIMA or AutoETS
- For baseline comparison: Use
Naive, SeasonalNaive, or HistoricAverage
- For seasonal data: Use models with
season_length parameter
- For sparse data: Use Croston family or ADIDA
- For multiple seasonalities: Use MSTL or TBATS
- For volatile data: Use GARCH or ARCH
- For ensemble approaches: Combine multiple models and compare performance
References
For detailed information on the statistical models and algorithms, please refer to the source code and the original academic papers referenced in the docstrings.