Back to models
Forecaster

STLForecaster

Categorical in XInsamplePred int insampleExogenous

Implements STLForecaster based on statsmodels.tsa.seasonal.STL implementation.

Quickstart

python
from sktime.forecasting.trend import STLForecaster

estimator = STLForecaster(sp=2, seasonal=7, trend=None, low_pass=None, seasonal_deg=1, trend_deg=1, low_pass_deg=1, robust=False, seasonal_jump=1, trend_jump=1, low_pass_jump=1, inner_iter=None, outer_iter=None, forecaster_trend=None, forecaster_seasonal=None, forecaster_resid=None)

Parameters(16)

spint, optional, default=2. Passed to statsmodels STL.

Length of the seasonal period passed to statsmodels STL. (forecaster_seasonal, forecaster_resid) that are None. The default forecaster_trend does not get sp as trend is independent to seasonality.

seasonalint, optional., default=7. Passed to statsmodels STL.
Length of the seasonal smoother. Must be an odd integer >=3, and should normally be >= 7 (default).
trend{int, None}, optional, default=None. Passed to statsmodels STL.
Length of the trend smoother. Must be an odd integer. If not provided uses the smallest odd integer greater than 1.5 * period / (1 - 1.5 / seasonal), following the suggestion in the original implementation.
low_pass{int, None}, optional, default=None. Passed to statsmodels STL.
Length of the low-pass filter. Must be an odd integer >=3. If not provided, uses the smallest odd integer > period.
seasonal_degint, optional, default=1. Passed to statsmodels STL.
Degree of seasonal LOESS. 0 (constant) or 1 (constant and trend).
trend_degint, optional, default=1. Passed to statsmodels STL.
Degree of trend LOESS. 0 (constant) or 1 (constant and trend).
low_pass_degint, optional, default=1. Passed to statsmodels STL.
Degree of low pass LOESS. 0 (constant) or 1 (constant and trend).
robustbool, optional, default=False. Passed to statsmodels STL.
Flag indicating whether to use a weighted version that is robust to some forms of outliers.
seasonal_jumpint, optional, default=1. Passed to statsmodels STL.
Positive integer determining the linear interpolation step. If larger than 1, the LOESS is used every seasonal_jump points and linear interpolation is between fitted points. Higher values reduce estimation time.
trend_jumpint, optional, default=1. Passed to statsmodels STL.
Positive integer determining the linear interpolation step. If larger than 1, the LOESS is used every trend_jump points and values between the two are linearly interpolated. Higher values reduce estimation time.
low_pass_jumpint, optional, default=1. Passed to statsmodels STL.
Positive integer determining the linear interpolation step. If larger than 1, the LOESS is used every low_pass_jump points and values between the two are linearly interpolated. Higher values reduce estimation time.
inner_iter: int or None, optional, default=None. Passed to ``statsmodels`` ``STL``.
Number of iterations to perform in the inner loop. If not provided uses 2 if robust is True, or 5 if not. This param goes into STL.fit() from statsmodels.
outer_iter: int or None, optional, default=None. Passed to ``statsmodels`` ``STL``.
Number of iterations to perform in the outer loop. If not provided uses 15 if robust is True, or 0 if not. This param goes into STL.fit() from statsmodels.
forecaster_trendsktime forecaster, optional

Forecaster to be fitted on trend_ component of the STL, by default None. If None, then a NaiveForecaster(strategy=”drift”) is used.

forecaster_seasonalsktime forecaster, optional

Forecaster to be fitted on seasonal_ component of the STL, by default None. If None, then a NaiveForecaster(strategy=”last”) is used.

forecaster_residsktime forecaster, optional

Forecaster to be fitted on resid_ component of the STL, by default None. If None, then a NaiveForecaster(strategy=”mean”) is used.

Examples

>>> from sktime.datasets import load_airline
>>> from sktime.forecasting.trend import STLForecaster
>>> y = load_airline ()
>>> forecaster = STLForecaster (sp = 12)
>>> forecaster. fit (y) STLForecaster(
... )
>>> y_pred = forecaster. predict (fh = [1, 2, 3 ])

References

  1. [1 ] R. B. Cleveland, W. S. Cleveland, J.E. McRae, and I. Terpenning (1990) STL: A Seasonal-Trend Decomposition Procedure Based on LOESS. Journal of Official Statistics, 6, 3-73. [2 ] https://www.statsmodels.org/dev/generated/statsmodels.tsa.seasonal.STL.html