DtwDtaidistUniv
DtwDtaidistUniv
- class DtwDtaidistUniv(use_c=False, window=None, max_dist=None, max_step=None, max_length_diff=None, penalty=None, psi=None, use_pruning=False)[source]
Univariate dynamic time warping distance, from dtaidistance.
Direct interface to
dtaidistance.dtw.distance_matrixanddtaidistance.dtw.distance_matrix_fast.This distance is specifically for univariate time series. While mathematically equivalent for using the multivariate
DtwDtaidistMultivfor univariate data, this class uses a more efficient implementation and a different internal API.To specify an inner scalar distance, use
DtwDtaidistMultivwith theinner_distparameter set to the desired scalar distance.- Parameters:
- use_c: bool, optional, default=False
Whether to use the faster C variant:
Truefor C,Falsefor Python.Truerequires a C compiled installation ofdtaidistance.If False, uses
dtaidistance.dtw.distance_matrix.If True, uses
dtaidistance.dtw.distance_matrix_fast.
- windowinteger, optional, default=infinite
Sakoe Chiba window width, from diagonal to boundary. Only allow for maximal shifts from the two diagonals smaller than this number. The maximally allowed warping, thus difference between indices i in series 1 and j in series 2, is thus |i-j| < 2*window + |len(s1) - len(s2)|. It includes the diagonal, meaning that Euclidean distance is obtained by setting
window=1.If the two series are of equal length, this means that the band appearing on the cumulative cost matrix is of width 2*window-1. In other definitions of DTW this number may be referred to as the window instead.- max_dist: float, optional, default=infinite
Stop if the returned values will be larger than this value.
- max_step: float, optional, default=infinite
Do not allow steps larger than this value. If the difference between two values in the two series is larger than this, thus if |s1[i]-s2[j]| > max_step, replace that value with infinity.
- max_length_diff: int, optional, default=infinite
Return infinity if difference of length of two series is larger than this value.
- penalty: float, optional, default=0
Penalty to add if compression or expansion is applied
- psi: integer or 4-tuple of integers or none, optional, default=none
Psi relaxation parameter (ignore start and end of matching). If psi is a single integer, it is used for both start and end relaxations for both series in a pair of series. If psi is a 4-tuple, it is used as the psi-relaxation for (begin series1, end series1, begin series2, end series2). Useful for cyclical series.
- use_pruning: bool, optional, default=False
Prune values based on Euclidean distance.
- Attributes:
is_fittedWhether
fithas been called.
References
[1]H. Sakoe, S. Chiba, “Dynamic programming algorithm optimization for spoken word recognition,” IEEE Transactions on Acoustics, Speech and Signal Processing, vol. 26(1), pp. 43–49, 1978.
Methods
__call__(X[, X2])Compute distance/kernel matrix, call shorthand.
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, X2])Fit method for interface compatibility (no logic inside).
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.
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.
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.
transform(X[, X2])Compute distance/kernel matrix.
transform_diag(X)Compute diagonal of distance/kernel matrix.

