Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

TypeError: 'module' object is not callable – while using UMAP

import umap as UMAP

import umap


retarget = {df_train['target'].value_counts().reset_index()['index'][i]: i for i in range(len(df_train['target'].value_counts()))}
retarget2 = {i: k for k, i in retarget.items()}
df_train['target'] = df_train['target'].map(retarget)

umap = umap(n_components = 2, n_neighbors = 10, min_dist = 0.99).fit_transform(df_train.drop('target', axis = 1).sample(15000, random_state = 228), df_train['target'].sample(15000, random_state = 228))

I am trying to use UMAP for visualization but it is keep on giving me error:

TypeError                                 Traceback (most recent call last)
<ipython-input-15-bb51a04f463b> in <module>
      8 df_train['target'] = df_train['target'].map(retarget)
      9 
---> 10 umap = umap(n_components = 2, n_neighbors = 10, min_dist = 0.99).fit_transform(df_train.drop('target', axis = 1).sample(15000, random_state = 228), df_train['target'].sample(15000, random_state = 228))
     11 
     12 plt.figure(figsize=(15, 12))

TypeError: 'module' object is not callable

I have umap installed in my system:

(base) C:\Users\bakumari\Anaconda3\Lib\site-packages>pip install umap
Collecting umap
  Using cached umap-0.1.1-py3-none-any.whl
Installing collected packages: umap
Successfully installed umap-0.1.1

I am trying to use umap for visualization purpose.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You need to install umap-learn

pip uninstall umap
pip install umap-learn

and then

import umap
umap = umap.UMAP(n_components = 2, n_neighbors = 10, min_dist = 0.99).fit_transform(df_train.drop('target', axis = 1).sample(15000, random_state = 228), df_train['target'].sample(15000, random_state = 228))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading