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

Attribute Error #24

Closed
Jhard01 opened this issue Nov 22, 2017 · 23 comments
Closed

Attribute Error #24

Jhard01 opened this issue Nov 22, 2017 · 23 comments

Comments

@Jhard01
Copy link

Jhard01 commented Nov 22, 2017

Hi there, these are my system specs:
macOS Sierra 10.12.3 (16D32)

I have installed umap through pip. When I try to run it this the error message that comes up. I'm unsure what the problem is, any ideas?

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-10-68ef34dfa695> in <module>()
     16         umap_mfccs = get_scaled_umap_embeddings(mfcc_features,
     17                                                 neighbours,
---> 18                                                 distances)
     19         umap_embeddings_mfccs.append(umap_mfccs)
     20 

<ipython-input-10-68ef34dfa695> in get_scaled_umap_embeddings(features, neighbour, distance)
      1 def get_scaled_umap_embeddings(features, neighbour, distance):
      2 
----> 3     embedding = umap.UMAP(n_neighbors=neighbour,
      4                           min_dist = distance,
      5                           metric = 'correlation').fit_transform(features)

AttributeError: module 'umap' has no attribute 'UMAP'

@lmcinnes
Copy link
Owner

Hi, I can't say for sure but potentially it may be that you actually have the wrong umap. Due to name collisions the UMAP algorithm code is under the name umap-learn on PyPI so if you did

pip install umap

you will get a different package that does not to what you want.

If that is the case then you'll want

pip uninstall umap
pip install umap-learn

If that is not the problem then there is something else wrong that is going to be harder to diagnose. Either way, please let me know, and sorry about the naming confusion on pip.

@Jhard01
Copy link
Author

Jhard01 commented Nov 23, 2017

I have tried this, unfortunately, had no luck regarding the name confusion on pip. I am going to look at this again, I will let you know if there is any progress.

@lmcinnes
Copy link
Owner

Thanks. I'm sorry I can't be more help but I currently can't reproduce the problem (or even have any idea what might be causing it). Please keep me updated. I'm sure it is frustrating and I appreciate your patience and willingness to try and work through it.

LGro added a commit to LGro/umap that referenced this issue Dec 1, 2017
@vedal
Copy link

vedal commented Jun 16, 2018

I encountered this error due to having named my python-file umap.py. Felt quite silly and changed filename, which solved the problem.

@sabyadg
Copy link

sabyadg commented Sep 21, 2018

I still get this error and have tried the umap-learn trick using conda install :( I am using Mac OS X (Sierra)

@matiasdahl
Copy link

I also had the same issue (import umap; umap.UMAP returns AttributeError: module 'umap' has no attribute 'UMAP') (MacOS, High Sierra, installed via pip).

As a workaround import umap.umap_ as umap seems to work instead of import umap

@tanghoiy
Copy link

I also had the same issue (import umap; umap.UMAP returns AttributeError: module 'umap' has no attribute 'UMAP') (MacOS, High Sierra, installed via pip).

As a workaround import umap.umap_ as umap seems to work instead of import umap

This seemed to get me around the original error (after also switching to installing umap-learn instead), but then my kernel died on attempting umap.UMAP().fit_transform().

(Datalab running on a Google Cloud Dataproc cluster)

@lmcinnes
Copy link
Owner

The best I can offer is that you need to make sure that the mapping based umap package has been completely purged from your python install before trying to install umap-learn. I would suggest finding the relevant site-packages directory and removing any and all files and directories there that start with umap and then trying to re-install umap-learn.

@Benz-Tracxpoint
Copy link

I am getting this problem too now upon my very first attempt to use UMAP. :(
I have taken care to only install umap-learn and not umap to begin with. The import umap.umap_ as umap workaround fails too.

Running from a Jupyter notebook with python 3.6 on an Ubuntu machine.

@sabyadg
Copy link

sabyadg commented Oct 7, 2018 via email

@SaKOLOURI
Copy link

SaKOLOURI commented Oct 17, 2018

I have the same problem , but at first my code worked without any problem but after some pip install of different library files it happens ,
umapdim=umap.UMAP(n_neighbors=20)
x_train_umap=umapdim.fit_transform(x_train,y=y_train)
x_test_umap=umapdim.transform(x_test)
fig,[ax1,ax2]=plt.subplots(1,2,figsize=(10,5))
ax1.scatter(x_train_umap[:,0],x_train_umap[:,1],c=y_train)
ax2.scatter(x_test_umap[:,0],x_test_umap[:,1],c=y_test)
plt.show()
svm.fit(x_train_umap,y_train)
y_test_predict=svm.predict(x_test_umap)
print((1.*(y_test_predict==y_test)).sum()/y_test.shape[0])
I had tried the above solution but they're not worked on my issue ., I have umap-learn and umap is not installed on my system .
is there any way to see witch library cause this conflict ?

@lmcinnes
Copy link
Owner

lmcinnes commented Oct 17, 2018 via email

@SaKOLOURI
Copy link

SaKOLOURI commented Oct 17, 2018 via email

@sabyadg
Copy link

sabyadg commented Oct 17, 2018 via email

@SaKOLOURI
Copy link

Yes sir ,I agree with you in this case , I'm a newcomer on python , but from my former experiences on other programming software (specially on Siemens software's ) it's some times the only way.

@muj1og
Copy link

muj1og commented Oct 28, 2018

I was facing the same problem too, I'm suing windows, conda versions, and what i did is that
pip uninstall umap-learn
pip install umap-learn
and then follow it
pip install umap

it just worked !

@tjrileywisc
Copy link

Not sure if this situation helps anyone (or is expected), but I ran into this situation when I tried to run transform() on new data, from a joblib pickle of a previous umap run, where that pickle was created from a previous release of umap.

I'm able to run transform() again after recreating the joblib pickle with the new version.

@yinleon
Copy link

yinleon commented Nov 30, 2018

Maybe we can look into by the joblib pickle works with scikit-learn models, but fails here...

@bashhwu
Copy link

bashhwu commented Mar 27, 2019

Actually, I have used the following:
pip uninstall umap

pip install umap-learn

Now on the notebook:
import umap.umap_ as umap
reducer=umap.UMAP()

It works well.

@00krishna
Copy link

Thanks for your excellent work on this package @lmcinnes . I know the problem is not related to the package itself, but just wanted to document it for tracking purposes. FYI I also ran into the same issue yesterday. I think I installed the other umap first then figured out that umap-learn was the right choice. After uninstalling the incorrect umap I had to still do a bunch of installs and uninstalls of umap-learn using conda and pip. Finally I made sure that site-packages was clean and did a few more installs. Finally got it to work. So there was lots of frustration, but eventually got it to work.

kevinrobinson added a commit to kevinrobinson/interpretability that referenced this issue Aug 19, 2019
@abhinabasaha
Copy link

I also had the same issue (import umap; umap.UMAP returns AttributeError: module 'umap' has no attribute 'UMAP') (MacOS, High Sierra, installed via pip).

As a workaround import umap.umap_ as umap seems to work instead of import umap

this has worked for me

@benrhodeland
Copy link

I just encountered this common problem today. Working from within a Jupyter Notebook I performed:

!pip install umap

Then

import umap
reducer = umap.UMAP()

caused the common error here. I installed 'umap-learn' but to no avail.

I corrected the issue by uninstalling 'umap', then also uninstalling 'umap-learn', then reinstalling 'umap-learn' and restarting my kernel:

!pip uninstall umap
!pip uninstall umap-learn
!pip install umap-learn

With this solution, I was then successful with:

import umap
reducer = umap.UMAP()

@sleighsoft
Copy link
Collaborator

The proper way to install UMAP is documented in the README.md.

Many people assume the package is called umap while instead it is called umap-learn.
Thank you for clarifying @benrhodeland.

In general: Read the README.

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

No branches or pull requests