Skip to content

MovingBlockBootstrapTransformer

MovingBlockBootstrapTransformer

class MovingBlockBootstrapTransformer(n_series: int = 10, block_length: int = 10, sampling_replacement: bool = False, return_actual: bool = True, random_state: int | RandomState = None, return_indices=False)[source]

Moving Block Bootstrapping method for synthetic time series generation.

The Moving Block Bootstrapping (MBB) method introduced in [1] is can be used to create synthetic time series that mimic the autocorelation patterns of an observed stationary series. This method is frequently combined with other transformations e.g. BoxCox and STL to produce synthetic time series similar to the observed time series [2], [3].

The returned panel will be a multiindex dataframe (pd.DataFrame) with the series_id and time_index as the index and a single column of the time series value. The values for series_id are “actual” for the original series and “synthetic_n” (where n is an integer) for the generated series. See the Examples section for example output.

Parameters:
n_seriesint, optional, default=10

The number of bootstrapped time series that will be generated

block_lengthint, optional, default = min(2*sp, len(X) - sp)

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, default=False

Whether the MBB sample is with or without replacement

return_actualbool, optional, default=True

If True the output will contain the actual time series. The actual time series will be labelled as “actual”.

random_stateint, np.random.RandomState or None, by default None

Controls the randomness of the estimator

return_indicesbool, optional, default=False.

If True, the output will contain the resampled indices as extra column.

Attributes:
is_fitted

Whether fit has been called.

See also

sktime.transformations.bootstrap.STLBootstrapTransformer

Transformer that utilises BoxCox, STL and Moving Block Bootstrapping to create a panel of similar time series.

References

[1]

Kunsch HR (1989) The jackknife and the bootstrap for general stationary observations. Annals of Statistics 17(3), 1217-1241

[2]

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

[3]

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. Accessed on February 13th 2022.

Examples

>>> from sktime.transformations.bootstrap import MovingBlockBootstrapTransformer
>>> from sktime.datasets import load_airline
>>> from sktime.utils.plotting import plot_series
>>> y = load_airline()
>>> transformer = MovingBlockBootstrapTransformer(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.0

Methods

check_is_fitted([method_name])

Check if the estimator has been fitted.

clone()

Obtain a clone of the object with same hyper-parameters and config.

clone_tags(estimator[, tag_names])

Clone tags from another object as dynamic override.

create_test_instance([parameter_set])

Construct an instance of the class, using first test parameter set.

create_test_instances_and_names([parameter_set])

Create list of all test instances and a list of names for them.

fit(X[, y])

Fit transformer to X, optionally to y.

fit_transform(X[, y])

Fit to data, then transform it.

get_class_tag(tag_name[, tag_value_default])

Get class tag value from class, with tag level inheritance from parents.

get_class_tags()

Get class tags from class, with tag level inheritance from parent classes.

get_config()

Get config flags for self.

get_fitted_params([deep])

Get fitted parameters.

get_param_defaults()

Get object's parameter defaults.

get_param_names([sort])

Get object's parameter names.

get_params([deep])

Get a dict of parameters values for this object.

get_tag(tag_name[, tag_value_default, ...])

Get tag value from instance, with tag level inheritance and overrides.

get_tags()

Get tags from instance, with tag level inheritance and overrides.

get_test_params([parameter_set])

Return testing parameter settings for the estimator.

inverse_transform(X[, y])

Inverse transform X and return an inverse transformed version.

is_composite()

Check if the object is composed of other BaseObjects.

load_from_path(serial)

Load object from file location.

load_from_serial(serial)

Load object from serialized memory container.

reset()

Reset the object to a clean post-init state.

save([path, serialization_format])

Save serialized self to bytes-like object or to (.zip) file.

set_config(**config_dict)

Set config flags to given values.

set_params(**params)

Set the parameters of this object.

set_random_state([random_state, deep, ...])

Set random_state pseudo-random seed parameters for self.

set_tags(**tag_dict)

Set instance level tag overrides to given values.

transform(X[, y])

Transform X and return a transformed version.

update(X[, y, update_params])

Update transformer with X, optionally y.