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

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

Problem Description:

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:UsersbakumariAnaconda3Libsite-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.

Solution – 1

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))
Rate this post
We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.
Accept
Reject