Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added fastdtw #8

Merged
merged 2 commits into from
Feb 16, 2017
Merged

Added fastdtw #8

merged 2 commits into from
Feb 16, 2017

Conversation

capkuro
Copy link
Contributor

@capkuro capkuro commented Feb 15, 2017

Hi, I'm implementing a speech comparison back-end and i used your library. In my journey of developing my application, I found out that the speed for calculating the DTW between a large number of MFCC coefficients is slow (in the context of my application). For that reason, fastdtw was implemented, by making use of scipy's cdist function which has optimised functions for calculating the distance between matrices.

This function supports giving the distance function as a parameter, or giving it as a string. If the latter is used, then cdist will be using an corresponding optimised function. Here below is a little code for time benchmarking purposes:

import numpy as np
from scipy.spatial.distance import cosine
from dtw import dtw, fastdtw
import timeit

x = np.random.rand(1000).reshape(-1,1)
y = np.random.rand(1000).reshape(-1,1)

start = timeit.default_timer()
fastdtw(x,y,cosine)
end = timeit.default_timer()
print ("DTW with scipy cosine distance:" ,end-start)
print "========"
start = timeit.default_timer()
fastdtw(x,y,'cosine')
end = timeit.default_timer()
print ("DTW with scipy cdist using cosine distance:",end-start)

And the output of this code in a I5-5gen with 8gb of ram is:

('DTW with scipy cosine distance:', 47.640693556034876)
========
('DTW with scipy cdist using cosine distance:', 1.4689458024448427)

Also, thanks for sharing your code.
Sebastian

@pierre-rouanet
Copy link
Member

Great add to the library! Thanks a lot!

@pierre-rouanet pierre-rouanet merged commit 2207f88 into pollen-robotics:master Feb 16, 2017
@ludovicamicaroni3
Copy link

Hi, If I install the package dtw it cannot find this function on the import. shall I install something else?

@pierre-rouanet
Copy link
Member

It has been renamed accelerated_dtw (see #28)

@pankeda123
Copy link

Hi, this is really a very easy to use package, thank you for providing. I am using it for clustering large amounts of data,so I use the ‘accelerated_dtw’ function for calculation. But function ‘accelerated_dtw’ seems to be unable to adjust the parameter ‘w’, is there a way to solve this problem?

@soso-maitha
Copy link

Thanks lot really this is much more faster than the dtw. If you have any paper let me know so that I reference it in my MSc. dissertation.
best regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants