0
$\begingroup$

I am trying to classify some time series using dtw-python package which is a python version of R package implementing Dynamic Time Warping described in this nice paper. By default a call to dtw function returns DTW object containing the distance as well as found warping path (docs).

Classification with K-Nearest-Neighbours requires computing DTW(X,Y) for each of possible pairs $X \in T, Y \in E$, where $T$ is a test set and $E$ is eval set. Results can be stored in $|T| \times |E|$ distances matrix $\lambda$ and later used to find the best matches. It is a lot of computations though. In the cited paper we can read that:

$\lambda$ can be straightforwardly computed through proxy::dist(q, q, method = "DTW"). Computing K × K alignments in this way is faster than iterating over the plain dtw call, because only the numeric value of the distance is computed, while the construction of the actual warping path is bypassed.

I don't need to know the warping paths so I'd like to use this approach. Unfortunately this is valid for R version only as proxy is R package. Can I do something equivalent so that dtw in dtw-python doesn't return warping paths and only the distance so that it is faster?

$\endgroup$
2
  • $\begingroup$ What function are you currently using to compute DTW? Without knowing anything about DTW and the package it seems that the dtw function has a keyword argument distance_only (see the docs) that can be used to only calculate the distance between two time series. $\endgroup$
    – Oxbowerce
    Jan 17, 2022 at 12:49
  • $\begingroup$ Wow, thanks. I didn't notice it somehow... I'll test it and see how much faster it is. $\endgroup$ Jan 17, 2022 at 13:12

1 Answer 1

0
$\begingroup$

What function are you currently using to compute DTW? Without knowing anything about DTW and the package it seems that the dtw function has a keyword argument distance_only (see the docs) that can be used to only calculate the distance between two time series.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.