ShapeletLearningClassifierPyts
ShapeletLearningClassifierPyts
- class ShapeletLearningClassifierPyts(loss='softmax', n_shapelets_per_size=0.2, min_shapelet_length=0.1, shapelet_scale=3, penalty='l2', tol=0.001, C=1000, learning_rate=1.0, max_iter=1000, multi_class='multinomial', alpha=-100, fit_intercept=True, intercept_scaling=1.0, class_weight=None, n_jobs=None, verbose=0, random_state=None)[source]
Learning Shapelets algorithm, from pyts.
Direct interface to
pyts.classification.LearningShapeletsorpyts.classification.LearningShapeletsCrossEntropy, author of the interfaced classes isjohannfaouzi.Dispatches to
LearningShapeletsorLearningShapeletsCrossEntropy, depending on the value of thelossparameter.This estimator consists of two steps: computing the distances between the shapelets and the time series, then carrying out empirical risk minimization using these distances as linear features. The risk is minimized using gradient descent; for
loss="softmax", this is mathematically equivalent to multinomial logistic regression on shapelet features. This algorithm learns the shapelets as well as the coefficients of the classification.- Parameters:
- lossstr (default = ‘softmax’), “softmax” or “crossentropy”
Loss function to use. If “softmax”, the loss function is the softmax function (logistic loss). Dispatches to
LearningShapelets. If “crossentropy”, the loss function is the cross-entropy loss. Dispatches toLearningShapeletsCrossEntropy.- n_shapelets_per_sizeint or float (default = 0.2)
Number of shapelets per size. If float, it represents a fraction of the number of timestamps and the number of shapelets per size is equal to
ceil(n_shapelets_per_size * n_timestamps).- min_shapelet_lengthint or float (default = 0.1)
Minimum length of the shapelets. If float, it represents a fraction of the number of timestamps and the minimum length of the shapelets per size is equal to
ceil(min_shapelet_length * n_timestamps).- shapelet_scaleint (default = 3)
The different scales for the lengths of the shapelets. The lengths of the shapelets are equal to
min_shapelet_length * np.arange(1, shapelet_scale + 1). The total number of shapelets (and features) is equal ton_shapelets_per_size * shapelet_scale.- penalty‘l1’ or ‘l2’ (default = ‘l2’)
Used to specify the norm used in the penalization.
- tolfloat (default = 1e-3)
Tolerance for stopping criterion.
- Cfloat (default = 1000)
Inverse of regularization strength. It must be a positive float. Smaller values specify stronger regularization.
- learning_ratefloat (default = 1.)
Learning rate for gradient descent optimization. It must be a positive float. Note that the learning rate will be automatically decreased if the loss function is not decreasing.
- max_iterint (default = 1000)
Maximum number of iterations for gradient descent algorithm.
- multi_class{‘multinomial’, ‘ovr’, ‘ovo’} (default = ‘multinomial’)
Strategy for multiclass classification. Only used if
loss="softmax". The options are as follows: ‘multinomial’ stands for multinomial cross-entropy loss. ‘ovr’ stands for one-vs-rest strategy. ‘ovo’ stands for one-vs-one strategy. Ignored if the classification task is binary.- alphafloat (default = -100)
Scaling term in the softmin function. The lower, the more precised the soft minimum will be. Default value should be good for standardized time series.
- fit_interceptbool (default = True)
Specifies if a constant (a.k.a. bias or intercept) should be added to the decision function.
- intercept_scalingfloat (default = 1.)
Scaling of the intercept. Only used if
fit_intercept=True.- class_weightdict, None or ‘balanced’ (default = None)
Weights associated with classes in the form
{class_label: weight}. If not given, all classes are supposed to have unit weight. The “balanced” mode uses the values of y to automatically adjust weights inversely proportional to class frequencies in the input data asn_samples / (n_classes * np.bincount(y)).- n_jobsNone or int (default = None)
The number of jobs to use for the computation. Only used if
loss="softmax"andmulti_classis “ovr” or “ovo”.- verboseint (default = 0)
Controls the verbosity. It must be a non-negative integer. If positive, loss at each iteration is printed.
- random_stateNone, int or RandomState instance (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 RandomState instance, random_state is the random number generator. If None, the random number generator is the RandomState instance used by np.random.
- Attributes:
- shapelets_array shape = (n_tasks, n_shapelets)
Learned shapelets. Each element of this array is a learned shapelet.
- coef_array, shape = (n_tasks, n_shapelets) or (n_classes, n_shapelets)
Coefficients for each shapelet in the decision function.
- intercept_array, shape = (n_tasks,) or (n_classes,)
Intercepts (a.k.a. biases) added to the decision function. If
fit_intercept=False, the intercepts are set to zero.- n_iter_array, shape = (n_tasks,)
Actual number of iterations.
Notes
The number of tasks (n_tasks) depends on the value of
multi_classand the number of classes. If there are two classes, the number of tasks is equal to 1. If there are more than two classes, the number of tasks is equal to:1 if
multi_class='multinomial'n_classes if
multi_class='ovr'n_classes * (n_classes - 1) / 2 if
multi_class='ovo'
References
[1]J. Grabocka, N. Schilling, M. Wistuba and L. Schmidt-Thieme, “Learning Time-Series Shapelets”. International Conference on Data Mining, 14, 392-401 (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.

