matrix-profile-foundation / matrixprofile

A Python 3 library making time series data mining tasks, utilizing matrix profile algorithms, accessible to everyone.
https://matrixprofile.org
Apache License 2.0
360 stars 62 forks source link

AttributeError: module 'matrixprofile' has no attribute 'datasets' #33

Closed elopezfune closed 4 years ago

elopezfune commented 4 years ago

I installed matrixprofile a week ago and I am trying to reproduce the example in the documentation https://matrixprofile.docs.matrixprofile.org/examples/ECG_Annotation_Vectors.html but as soon as I arrive to

import matrixprofile as mp
import numpy as np

from matplotlib import pyplot as plt
%matplotlib inline

ecg = mp.datasets.load('ecg-heartbeat-av')
ts = ecg['data']
window_size = 150

I get the error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-11-93a2bc01725a> in <module>
      6 
      7 
----> 8 ecg = mp.datasets.load('ecg-heartbeat-av')
      9 ts = ecg['data']
     10 window_size = 150

AttributeError: module 'matrixprofile' has no attribute 'datasets'

I even tried mp.compute and I got the error

AttributeError: module 'matrixprofile' has no attribute 'compute'

Am I doing something wrong or are there missing packages or....?

tylerwmarrs commented 4 years ago

It appears that you are using a different library having the same namespace. What is the output of pip freeze?

elopezfune commented 4 years ago

The output is matrixprofile==1.1.2 matrixprofile-ts==0.0.9

tylerwmarrs commented 4 years ago

Yes, this is the problem. matrixprofile-ts has the same namespace and is more than likely the library being imported. Either create a new conda/virtual environment for matrixprofile or uninstall matrixprofile-ts. The latter library is no longer maintained.

elopezfune commented 4 years ago

I did but now it gives me another error


AttributeError Traceback (most recent call last)

in 10 ax.plot(np.arange(len(vals)),vals, label = 'Test Data') 11 ---> 12 profile, figures = mp.analyze(vals) AttributeError: module 'matrixprofile' has no attribute 'analyze'
tylerwmarrs commented 4 years ago

Please post the imports, pip freeze results, mp.__dict__ output, and mp.__version__ output.

elopezfune commented 4 years ago

I am reproducing the example in https://github.com/matrix-profile-foundation/article-matrix-profile-intro/blob/master/Matrix%20Profile%20Example.ipynb

import matrixprofile as mp

mp.__dict__
{'__name__': 'matrixprofile',
 '__doc__': None,
 '__package__': 'matrixprofile',
 '__loader__': <_frozen_importlib_external._NamespaceLoader at 0x7f3393fe00b8>,
 '__spec__': ModuleSpec(name='matrixprofile', loader=None, origin='namespace', submodule_search_locations=_NamespacePath(['/home/elopezfune/.local/lib/python3.6/site-packages/matrixprofile'])),
 '__path__': _NamespacePath(['/home/elopezfune/.local/lib/python3.6/site-packages/matrixprofile'])}

mp.__version__

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-12-93d9f20194b9> in <module>
----> 1 mp.__version__

AttributeError: module 'matrixprofile' has no attribute '__version__'
tylerwmarrs commented 4 years ago

What about pip freeze? This still seems to be an environmental issue.

elopezfune commented 4 years ago

the pip freeze gives matrixprofile==1.1.2 pip freeze results gives the same matrixprofile==1.1.2

tylerwmarrs commented 4 years ago

Please try the following:

  1. create a virtual environment
# via conda
conda create --name mptest

# via virtualenv
virtualenv mptest
  1. activate the environment
# via conda
conda activate mptest

# via virtualenv (may be different for Windows)
source mptest/bin/activate

3.a install pip

If you are using conda, you may need to install pip.

conda install pip

3.b install matrixprofile

pip install matrixprofile
  1. run this script within your virtual environment
    
    import matrixprofile as mp
    import numpy as np

ts = np.arange(100) profile, figures = mp.analyze(ts)



You should not receive any errors when going through these steps unless there is some larger environmental issue. Maybe one issue is that your notebook does not have the same environment as you expect?
elopezfune commented 4 years ago

Well, I tried your procedure and I am still getting

(mptest) elopezfune@elopezfune:~$ python3 '/home/elopezfune/Téléchargements/legend.py' Traceback (most recent call last): File "/home/elopezfune/Téléchargements/legend.py", line 5, in profile, figures = mp.analyze(ts) AttributeError: module 'matrixprofile' has no attribute 'analyze'

vanbenschoten commented 4 years ago

I'd recommend un-installing matrixprofile-ts, as it's probably a namespace collision between packages.

On Sat, Jul 4, 2020, 9:56 AM Ernesto Lopez Fune notifications@github.com wrote:

Well, I tried your procedure and I am still getting

(mptest) elopezfune@elopezfune:~$ python3 '/home/elopezfune/Téléchargements/legend.py' Traceback (most recent call last): File "/home/elopezfune/Téléchargements/legend.py", line 5, in profile, figures = mp.analyze(ts) AttributeError: module 'matrixprofile' has no attribute 'analyze'

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/matrix-profile-foundation/matrixprofile/issues/33#issuecomment-653775622, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB53ISBIBQFEY5F3KE7VERDRZ47LPANCNFSM4OPRMHAA .

tylerwmarrs commented 4 years ago

@elopezfune do you have any further updates on this issue? It may be easier to debug in our Discord chat. You can find a link within the code repository Readme

elopezfune commented 4 years ago

I am re-installing everything from the beginning

elopezfune commented 4 years ago

So, I uninstalled matrixprofile and re-installed everything from the beginning. Now ModuleNotFoundError: No module named 'matrixprofile' when importing I think I will look for other alternatives to Motif discovery Thanks for the help anyways!

tylerwmarrs commented 4 years ago

Thank you for the update. Good luck.