Quote:
| Originally Posted by JavertKurtz Having the same problem - did you ever figure it out? |
I never got MLPY installed, but I did find a good workaround. I used the RPY2 library to access R from Python. R has a Dynamic Time Warping module. It meant I had to install R, install the dtw module, install RPY2, plus figure out how to use it all, but it did work.
R: (http : // www . r-project . org)
RPY2: (http : // rpy . sourceforge .net / rpy2 . html)
dtw package for R: (http : // dtw . r-forge . r-project . org)
(the links have spaces in because new users aren't allowed to post links, even if they are helpful, stupid rule)
Here's some Python code that should work once you have RPY2, R, and the dtw module installed (install dtw from within R once you have R).
Code:
import pylab
from rpy2.robjects.packages import importr
from rpy2 import robjects
from rpy2 import rinterface
import rpy2.robjects.numpy2ri
rpy2.robjects.numpy2ri.activate()
R = rpy2.robjects.r
DTW = importr('dtw')
# Calculate the alignment and DTW distance
alignment = R.dtw(query, reference, keep=True)
distance = alignment.rx('distance')[0][0]
# Plot the warped curve
warpIndexes=R.warp(alignment,True)
pylab.plot(warpIndexes,query)
# Some plotting stuff inside R:
# Show the alignment
R.X11()
R.dtwPlotTwoWay(alignment)
# Show the warping function
R.X11()
R.dtwPlotThreeWay(alignment,main="")
# You can call this to refresh the R windows if you resize them
rinterface.process_revents()
I hope that helps!
(By the way I had to register a new account because this forum's password reset doesn't work)