visualizing LDA model using pyLDAvis

648 Views Asked by At

I'm running jupyter notebook in vscode. I have build my LDA model using gensim but when I want to visualize it, it shows nothing.

my code is:

import pyLDAvis 
import pyLDAvis.gensim_models

pyLDAvis.enable_notebook(local=True)
vis = pyLDAvis.gensim_models.prepare(lda_model, corpus, id2word)

vis

I tried display method of pyLDAvis it didn't work neither

I'm expecting some plots and graphs like this address

2

There are 2 best solutions below

1
Mhmmd On

I found some answer for it. It still wont work on jupyter extension of VScode but on jupyterlab on browser it works.

0
Ichta On

You need to apply a display method on the prepared data for the visualization to show up. Try this:

import pyLDAvis 
import pyLDAvis.gensim_models

pyLDAvis.enable_notebook(local=True)
vis = pyLDAvis.gensim_models.prepare(lda_model, corpus, id2word)

pyLDAvis.display(vis)