Skip to content

ShapeletLearningClassifierTslearn

ShapeletLearningClassifierTslearn

class ShapeletLearningClassifierTslearn(n_shapelets_per_size=None, max_iter=10000, batch_size=256, optimizer='sgd', weight_regularizer=0.0, shapelet_length=0.15, total_lengths=3, max_size=None, scale=False, verbose=0, random_state=None)[source]

Learning Time Series Shapelets Classifier, from tslearn.

Direct interface to tslearn.shapelets.shapelets.LearningShapelets.

Learning Time-Series Shapelets was originally presented in [1].

Parameters:
n_shapelets_per_size: dict (default: None)

Dictionary giving, for each shapelet size (key), the number of such shapelets to be trained (value). If None, grabocka_params_to_shapelet_size_dict is used and the size used to compute is that of the shortest time series passed at fit time.

max_iter: int (default: 10,000)

Number of training epochs.

batch_size: int (default: 256)

Batch size to be used.

optimizer: str or keras.optimizers.Optimizer (default: “sgd”)

keras optimizer to use for training.

weight_regularizer: float or None (default: 0.)

Strength of the L2 regularizer to use for training the classification (softmax) layer. If 0, no regularization is performed.

shapelet_length: float (default: 0.15)

The length of the shapelets, expressed as a fraction of the time series length. Used only if n_shapelets_per_size is None.

total_lengths: int (default: 3)

The number of different shapelet lengths. Will extract shapelets of length i * shapelet_length for i in [1, total_lengths] Used only if n_shapelets_per_size is None.

max_size: int or None (default: None)

Maximum size for time series to be fed to the model. If None, it is set to the size (number of timestamps) of the training time series.

scale: bool (default: False)

Whether input data should be scaled for each feature of each time series to lie in the [0-1] interval. Default for this parameter is set to False in version 0.4 to ensure backward compatibility, but is likely to change in a future version.

verbose: {0, 1, 2} (default: 0)

keras verbose level.

random_stateint or None, optional (default: None)

The seed of the pseudo random number generator to use when shuffling the data. If int, random_state is the seed used by the random number generator; If None, the random number generator is the RandomState instance used by np.random.

Attributes:
shapelets_numpy.ndarray of objects, each object being a time series

Set of time-series shapelets.

shapelets_as_time_series_numpy.ndarray of shape (n_shapelets, sz_shp, d)

where sz_shp is the maximum of all shapelet sizes Set of time-series shapelets formatted as a tslearn time series dataset.

transformer_model_keras.Model

Transforms an input dataset of timeseries into distances to the learned shapelets.

locator_model_keras.Model

Returns the indices where each of the shapelets can be found (minimal distance) within each of the timeseries of the input dataset.

model_keras.Model

Directly predicts the class probabilities for the input timeseries.

history_dict

Dictionary of losses and metrics recorded during fit.

References

[1]
  1. Grabocka et al. Learning Time-Series Shapelets. SIGKDD 2014.

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 time series classifier to training data.

fit_predict(X, y[, cv, change_state])

Fit and predict labels for sequences in X.

fit_predict_proba(X, y[, cv, change_state])

Fit and predict labels probabilities for sequences in X.

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.

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.

predict(X)

Predicts labels for sequences in X.

predict_proba(X)

Predicts labels probabilities for sequences in X.

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.

score(X, y)

Scores predicted labels against ground truth labels on X.

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.