Back to models
Detector

WindowSegmenter

Window-based Time Series Segmentation via Clustering.

In this we get overlapping and non overlapping subseries using a Sliding window. After that we run a clustering algorithm of our choosing to segment the time series.

Labels from overlapping segments are aggregated to get the final labels, via a majority vote.

Quickstart

python
from sktime.detection.wclust import WindowSegmenter

estimator = WindowSegmenter(clusterer=None, window_size=1, overlap=False, step_size=1, return_segments=True)

Parameters(5)

clusterersktime clusterer, BaseClusterer instance
The instance of clustering algorithm used for segmentation.
window_sizeInteger
The size of the Sliding Window
overlapBoolean, default=False
If True, overlapping windows are used.
step_sizeInteger, default=1
The step size for the sliding window.
return_segmentsBoolean, default=True
If True, returns the segments with the labels. If False, returns the labels for each time point.

Examples

>>> import pandas as pd
>>> from sklearn.cluster import KMeans
>>> from sktime.detection.wclust import WindowSegmenter
>>> X = pd. DataFrame ({ "a": [1, 1, 1, 1, 10, 10, 10, 10 ]})
>>> segmenter = WindowSegmenter (
... clusterer = KMeans (n_clusters = 2, random_state = 0, n_init = 10), window_size = 2
... )
>>> _ = segmenter. fit (X)
>>> result = segmenter. predict (X)
>>> result ilocs cluster 0 [0, 4) 1 1 [4, 7) 0