Rav*_*ati 3 visualization lda gensim pyldavis
import pyLDAvis.gensim
# Visualize the topics
pyLDAvis.enable_notebook()
vis = pyLDAvis.gensim.prepare(lda_model, corpus, id2word)
vis
Run Code Online (Sandbox Code Playgroud)
上面的代码在 google colab 中显示了 LDA 模型的可视化,但在重新打开笔记本后它停止显示。我什至试过
pyLDAvis.display(vis, template_type='notebook')
还是不行
当我设置
pyLDAvis.enable_notebook(local=True)
在此处输入图像描述 它确实显示结果但不显示标签.. 任何帮助将不胜感激!
小智 7
安装 LDAvis 时,请确保将版本指定为 2.1.2:
!pip install pyLDAvis==2.1.2
Run Code Online (Sandbox Code Playgroud)
新版本似乎不太适合 colab。
他们更改了包名称。像这样使用它:
import pyLDAvis.gensim_models
vis = pyLDAvis.gensim_models.prepare(lda_model, corpus, id2word)
vis
Run Code Online (Sandbox Code Playgroud)