Back to models
Transformer

ShapeletTransformPyts

Shapelet Transform, from pyts.

Quickstart

python
from sktime.transformations.shapelet_transform import ShapeletTransformPyts

estimator = ShapeletTransformPyts(n_shapelets='auto', criterion='mutual_info', window_sizes='auto', window_steps=None, remove_similar=True, sort=False, verbose=0, random_state=None, n_jobs=None)

Parameters(9)

n_shapeletsint or ‘auto’ (default = ‘auto’)

The number of shapelets to keep. If ‘auto’, n_timestamps // 2 shapelets are considered, where n_timestamps is the number of time points in the dataset. Note that there might be a smaller number of shapelets if fewer than n_shapelets shapelets have been extracted during the search.

criterion‘mutual_info’ or ‘anova’ (default = ‘mutual_info’)
Criterion to perform the selection of the shapelets. ‘mutual_info’ uses the mutual information, while ‘anova’ use the ANOVA F-value.
window_sizesarray-like or ‘auto ‘(default = ‘auto’)

Size of the sliding windows. If ‘auto’, the range for the window sizes is determined automatically. Otherwise, all the elements must be either integers or floats. In the latter case, each element represents the percentage of the size of each time series and must be between 0 and 1; the size of the sliding windows will be computed as np.ceil(window_sizes * n_timestamps).

window_stepsNone or array-like (default = None)

Step of the sliding windows. If None, each window_step is equal to 1. Otherwise, all the elements must be either integers or floats. In the latter case, each element represents the percentage of the size of each time series and must be between 0 and 1; the step of the sliding windows will be computed as np.ceil(window_steps * n_timestamps). Must be None if window_sizes='auto'.

remove_similarbool (default = True)
If True, self-similar shapelets are removed, keeping only the non-self-similar shapelets with the highest scores. Two shapelets are considered to be self-similar if they are taken from the the same time series and have at least one overlapping index.
sortbool (default = False)
If True, shapelets are sorted in descending order according to their associated scores. If False, the order is undefined.
verboseint (default = 0)
Verbosity level when fitting: if non zero, progress messages are printed. Above 50, the output is sent to stdout. The frequency of the messages increases with the verbosity level.
random_stateint, RandomState instance or None (default = None)

If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random. Only used if window_sizes='auto' in order to subsample the dataset to find the best range or if criterion=='mutual_info' to add small noise to the data.

n_jobsNone or int (default = None)

The number of jobs to run in parallel for fit. If -1, then the number of jobs is set to the number of cores.

Examples

>>> from sktime.transformations.shapelet_transform import (
... ShapeletTransformPyts
... )
>>> from sktime.datasets import load_unit_test
>>> X_train, y_train = load_unit_test (split = "train")
>>> stp = ShapeletTransformPyts ()
>>> stp. fit (X_train, y_train)
>>> stp. transform (X_train)

References

  1. [1 ] J. Lines, L. M. Davis, J. Hills and A. Bagnall, “A Shapelet Transform for Time Series Classification”. Data Mining and Knowledge Discovery, 289-297 (2012).