Transformer
STLBootstrapTransformer
Creates a population of similar time series.
Quickstart
python
from sktime.transformations.bootstrap import STLBootstrapTransformer
estimator = STLBootstrapTransformer(n_series: int=10, sp: int=12, block_length: int=None, sampling_replacement: bool=False, return_actual: bool=True, lambda_bounds: tuple=None, lambda_method: str='guerrero', seasonal: int=7, trend: int=None, low_pass: int=None, seasonal_deg: int=1, trend_deg: int=1, low_pass_deg: int=1, robust: bool=False, seasonal_jump: int=1, trend_jump: int=1, low_pass_jump: int=1, inner_iter: int=None, outer_iter: int=None, random_state: int | RandomState=None, return_indices=False)Parameters(21)
- n_seriesint, optional
- The number of bootstrapped time series that will be generated, by default 10.
- spint, optional
- Seasonal periodicity of the data in integer form, by default 12. Must be an integer >= 2
- block_lengthint, optional
- The length of the block in the MBB method, by default None. If not provided, the following heuristic is used, the block length will the minimum between 2*sp and len(X) - sp.
- sampling_replacementbool, optional
- Whether the MBB sample is with or without replacement, by default False.
- return_actualbool, optional
- If True the output will contain the actual time series, by default True. The actual time series will be labelled as “<series_name>_actual” (or “actual” if series name is None).
- lambda_boundsTuple, optional
- BoxCox parameter: Lower and upper bounds used to restrict the feasible range when solving for the value of lambda, by default None.
- lambda_methodstr, optional
- BoxCox parameter: {“pearsonr”, “mle”, “all”, “guerrero”}, by default “guerrero”. The optimization approach used to determine the lambda value used in the Box-Cox transformation.
- seasonalint, optional
- STL parameter: Length of the seasonal smoother. Must be an odd integer, and should normally be >= 7, by default 7.
- trendint, optional
- STL parameter: Length of the trend smoother, by default None. 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_passint, optional
- STL parameter: Length of the low-pass filter, by default None. Must be an odd integer >=3. If not provided, uses the smallest odd integer > period
- seasonal_degint, optional
- STL parameter: Degree of seasonal LOESS. 0 (constant) or 1 (constant and trend), by default 1.
- trend_degint, optional
- STL parameter: Degree of trend LOESS. 0 (constant) or 1 (constant and trend), by default 1.
- low_pass_degint, optional
- STL parameter: Degree of low pass LOESS. 0 (constant) or 1 (constant and trend), by default 1.
- robustbool, optional
- STL parameter: Flag indicating whether to use a weighted version that is robust to some forms of outliers, by default False.
- seasonal_jumpint, optional
- STL parameter: Positive integer determining the linear interpolation step, by default 1. 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
- STL parameter: Positive integer determining the linear interpolation step, by default 1. 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
- STL parameter: Positive integer determining the linear interpolation step, by default 1. 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_iterint, optional
- STL parameter: Number of iterations to perform in the inner loop, by default None. If not provided uses 2 if robust is True, or 5 if not. This param goes into STL.fit() from statsmodels.
- outer_iterint, optional
- STL parameter: Number of iterations to perform in the outer loop, by default None. If not provided uses 15 if robust is True, or 0 if not. This param goes into STL.fit() from statsmodels.
- random_stateint, np.random.RandomState or None, by default None
- Controls the randomness of the estimator
- return_indicesbool, optional
- If True, the output will contain the resampled indices as extra column, by default False.
Examples
>>> from sktime.transformations.bootstrap import STLBootstrapTransformer
>>> from sktime.datasets import load_airline
>>> from sktime.utils.plotting import plot_series
>>> y = load_airline ()
>>> transformer = STLBootstrapTransformer (10)
>>> y_hat = transformer. fit_transform (y)
>>> series_list = []
>>> names = []
>>> for group, series in y_hat. groupby (level = 0, as_index = False):
... series. index = series. index. droplevel (0)
... series_list. append (series)
... names. append (group)
>>> plot_series (* series_list, labels = names) (
... )
>>> print (y_hat. head ()) Number of airline passengers series_id time_index actual 1949-01 112.0 1949-02 118.0 1949-03 132.0 1949-04 129.0 1949-05 121.0References
- [1 ] Bergmeir, C., Hyndman, R. J., & Benítez, J. M. (2016). Bagging exponential smoothing methods using STL decomposition and Box-Cox transformation. International Journal of Forecasting, 32(2), 303-312 [2 ] Hyndman, R.J., & Athanasopoulos, G. (2021) Forecasting: principles and practice, 3rd edition, OTexts: Melbourne, Australia. OTexts.com/fpp3, Chapter 12.5. Accessed on February 13th 2022. [3 ] Kunsch HR (1989) The jackknife and the bootstrap for general stationary observations. Annals of Statistics 17(3), 1217-1241 [4 ] https://www.statsmodels.org/dev/generated/statsmodels.tsa.seasonal.STL.html