#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    1
    Rep Power
    0

    Using MLPY on a mac


    Hi people, I hope someone can help me with this.

    I'm trying to use MLPY on a mac, I've installed it (though maybe not properly), but when I type "import mlpy" in Python I get this error:

    Code:
    import mlpy
    ---------------------------------------------------------------------------
    ImportError                               Traceback (most recent call last)
    /Users/revans/Programming/Python/<ipython-input-22-f4eb31cdba5b> in <module>()
    ----> 1 import mlpy
    
    /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/mlpy/__init__.py in <module>()
         16     from .lcs import *
         17 else:
    ---> 18     import gsl
         19     from libsvm import *
         20     from liblinear import *
    
    ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/mlpy/gsl.so, 2): Symbol not found: _gsl_sf_fact
      Referenced from: /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/mlpy/gsl.so
      Expected in: dynamic lookup
    So it seems like there is some kind of problem with GSL. I installed GSL with macports, and from the website, but python can't seem to find it. If I type "import gsl" in Python I get:

    Code:
    import gsl
    ---------------------------------------------------------------------------
    ImportError                               Traceback (most recent call last)
    /Users/robertevans/Programming/Python/<ipython-input-23-426c2d498189> in <module>()
    ----> 1 import gsl
    
    ImportError: No module named gsl
    I think perhaps I need to set a path or something like that. Anyone know?

    Failing that, anybody know any other good Python libraries that come with Dynamic Time Warping?

    Thanks.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    2
    Rep Power
    0
    Having the same problem - did you ever figure it out?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    1
    Rep Power
    0
    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)
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    2
    Rep Power
    0
    Good to know - thanks!
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    1
    Rep Power
    0

    Fix


    I fixed the missing gsl problem by installing pygsl.

IMN logo majestic logo threadwatch logo seochat tools logo