Created
August 22, 2019 06:33
-
-
Save nbenn/c05e394d6384aac4cbc82a86d6608742 to your computer and use it in GitHub Desktop.
Comparison of python tslearn and R dtw implementations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(reticulate) | |
library(dtw) | |
use_condaenv("dtw") | |
tslearn <- import("tslearn") | |
tslearn$metrics$dtw(rep(0, 3), 1:4) | |
dtw(rep(0, 3), 1:4, keep.internals = T, step.pattern = symmetric1)[ | |
c("distance", "costMatrix") | |
] | |
dtw(dist(rep(0, 3), 1:4), keep.internals = T, step.pattern = symmetric1)[ | |
c("distance", "costMatrix") | |
] | |
dtw(dist(rep(0, 3), 1:4) ^ 2, keep.internals = T, step.pattern = symmetric1)[ | |
c("distance", "costMatrix") | |
] | |
sqrt(30) | |
idx <- seq(0, 6.28, len = 100); | |
x <- sin(idx) + runif(100) / 10; | |
y <- cos(idx) | |
tslearn$metrics$dtw(x, y) | |
sqrt(dtw(dist(x, y) ^ 2, step.pattern = symmetric1)[["distance"]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment