Classifier
ShapeDTW
ShapeDTW classifier.
Quickstart
python
from sktime.classification.distance_based import ShapeDTW
estimator = ShapeDTW(n_neighbors=1, subsequence_length=30, shape_descriptor_function='raw', shape_descriptor_functions=None, metric_params=None, n_splits=10)Parameters(7)
- n_neighborsint, int, set k for knn (default =1).
- subsequence_lengthint, defines the length of the
- subsequences(default=sqrt(n_timepoints)).
- shape_descriptor_functionstring, defines the function to describe
- the set of subsequences (default = ‘raw’).
- The possible shape descriptor functions are as follows:
- ‘raw’use the raw subsequence as the
shape descriptor function.
params = None
- ‘raw’use the raw subsequence as the
- shape_descriptor_functionsstring list, only applicable when the
- shape_descriptor_function is set to ‘compound’. Use a list of shape descriptor functions at the same time. (default = [‘raw’,’derivative’])
- metric_paramsdictionary for metric parameters
- (default = None).
- n_splitsint, number of splits for cross-validation
- (default = 10). Used for finding the weighting_factor if ‘shape_descriptor_function’ is set to ‘compound’ and weighting_factor is not given in ‘metric_params’.
Examples
>>> from sktime.classification.distance_based import ShapeDTW
>>> from sktime.datasets import load_unit_test
>>> X_train, y_train = load_unit_test (split = "train")
>>> X_test, y_test = load_unit_test (split = "test")
>>> clf = ShapeDTW (n_neighbors = 1,
... subsequence_length = 30,
... shape_descriptor_function = "raw",
... shape_descriptor_functions = None,
... metric_params = None,
... )
>>> clf. fit (X_train, y_train) ShapeDTW(
... )
>>> y_pred = clf. predict (X_test)