Back to models
Transformer

SlidingWindowSegmenter

Sliding window segmenter transformer.

This class is to transform a univariate series into a multivariate one by extracting sets of subsequences. It does this by firstly padding the time series on either end floor(window_length/2) times. Then it performs a sliding window of size window_length and hop size 1.

e.g. if window_length = 3

S = 1,2,3,4,5, floor(3/2) = 1 so S would be padded as

1,1,2,3,4,5,5

then SlidingWindowSegmenter would extract the following:

(1,1,2),(1,2,3),(2,3,4),(3,4,5),(4,5,5)

the time series is now a multivariate one.

Quickstart

python
from sktime.transformations.segment import SlidingWindowSegmenter

estimator = SlidingWindowSegmenter(window_length=5)

Parameters(2)

window_lengthint, optional, default=5.
length of sliding window interval
Used by the ShapeDTW algorithm.

Examples

>>> import pandas as pd
>>> from sktime.transformations.segment import SlidingWindowSegmenter
>>> X = pd. DataFrame ({ "a": [1, 2, 3, 4, 5 ]})
>>> t = SlidingWindowSegmenter (window_length = 3)
>>> t. fit_transform (X) 0 1 2 3 4 0 1 1 2 3 4 1 1 2 3 4 5 2 2 3 4 5 5 The output always has window_length rows and as many columns as there are original time points, regardless of the window size:
>>> t2 = SlidingWindowSegmenter (window_length = 2)
>>> t2. fit_transform (X) 0 1 2 3 4 0 1 1 2 3 4 1 1 2 3 4 5