Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No module named pyLDAvis

I can't import pyLDAvis.

It is installed but for some reason, I can not import it.

I tried

conda update anaconda

pip install --upgrade pip

pip install --upgrade jupyter notebook

pip install pyLDAvis

Installing pyLDAvis returns the message 'requirement already satisfied'. So I tried uninstalling and reinstalled the package but still doesn't work. This never happened with any other packages.

How can I solve this problem?

like image 870
Dohun Avatar asked Mar 23 '21 08:03

Dohun


Video Answer


2 Answers

The pyLDAvis gensim name changed. When I use gensim_models rather than gensim the interactive viz works.

The 'gensim_models' name is in the latest commit to bmabey's repo.

import pyLDAvis
import pyLDAvis.gensim_models as gensimvis
pyLDAvis.enable_notebook()

# feed the LDA model into the pyLDAvis instance
lda_viz = gensimvis.prepare(ldamodel, corpus, dictionary)
like image 165
script_kitty Avatar answered Sep 22 '22 23:09

script_kitty


Following code worked for me and I'm using Google Colaboratory.

!pip install pyLDAvis

import pyLDAvis
import pyLDAvis.gensim_models

pyLDAvis.enable_notebook()
vis = pyLDAvis.gensim_models.prepare(ldamodel, doc_term_matrix, dictionary)
vis
like image 39
Oshidi Avatar answered Sep 21 '22 23:09

Oshidi