tslearn.metrics

This modules delivers time-series specific metrics to be used at the core of machine learning algorithms.

Dynamic Time Warping

Dynamic Time Warping (DTW) is one of the most popular time-series dissimilarity scores. It consists in computing Euclidean distance between aligned time series. To do so, it needs to both determine the optimal alignment between time series and compute the associated cost, which is done (using dynamic programming) by computing the optimal path in a similarity matrix.

In the implementation included in tslearn, standard transition steps are used: diagonal, horizontal and vertical and DTW is computed as the Euclidean distance along the optimal path.

../_images/dtw.png

Example DTW path.

The tslearn.metrics module gathers time series similarity metrics.

Functions

cdist_dtw(dataset1[, dataset2, …]) Compute cross-similarity matrix using Dynamic Time Warping (DTW) similarity measure.
cdist_gak(dataset1[, dataset2, sigma]) Compute cross-similarity matrix using Global Alignment kernel (GAK).
dtw(s1, s2[, global_constraint, …]) Compute Dynamic Time Warping (DTW) similarity measure between (possibly multidimensional) time series and return it.
dtw_path(s1, s2[, global_constraint, …]) Compute Dynamic Time Warping (DTW) similarity measure between (possibly multidimensional) time series and return both the path and the similarity.
dtw_subsequence_path(subseq, longseq) Compute sub-sequence Dynamic Time Warping (DTW) similarity measure between a (possibly multidimensional) query and a long time series and return both the path and the similarity.
gak(s1, s2[, sigma]) Compute Global Alignment Kernel (GAK) between (possibly multidimensional) time series and return it.
soft_dtw(ts1, ts2[, gamma]) Compute Soft-DTW metric between two time series.
cdist_soft_dtw(dataset1[, dataset2, gamma]) Compute cross-similarity matrix using Soft-DTW metric.
cdist_soft_dtw_normalized(dataset1[, …]) Compute cross-similarity matrix using a normalized version of the Soft-DTW metric.
lb_envelope(ts[, radius]) Compute time-series envelope as required by LB_Keogh.
lb_keogh(ts_query[, ts_candidate, radius, …]) Compute LB_Keogh.
sigma_gak(dataset[, n_samples, random_state]) Compute sigma value to be used for GAK.
gamma_soft_dtw(dataset[, n_samples, …]) Compute gamma value to be used for GAK/Soft-DTW.