来自gensim的pyLDAvis可视化未在googlecolab中显示结果
import pyLDAvis.gensim
# Visualize the topics
pyLDAvis.enable_notebook()
vis = pyLDAvis.gensim.prepare(lda_model, corpus, id2word)
vis
上面的代码在 google colab 中显示了 LDA 模型的可视化,但在重新打开笔记本后它停止显示。我什至试过
pyLDAvis.display(vis, template_type='notebook')
还是不行
当我设置
pyLDAvis.enable_notebook(local=True)
在此处输入图像描述
它确实显示结果但不显示标签.. 任何帮助将不胜感激!
回答
安装 LDAvis 时,请确保将版本指定为 2.1.2:
!pip install pyLDAvis==2.1.2
新版本似乎不太适合 colab。