[英]Why pyLDAvis graph does not display topic keywords on the bar chart?
我正在尝试使用 PyLDAvis 可视化 LDA Model 的结果。 我设法让图表显示在 jupyter notebook 中,但是,描述主题的关键字标签(在条形图上)丢失了。
下面是使用虚拟数据的代码示例。
import numpy as np
import pandas as pd
import gensim
import gensim.corpora as corpora
import matplotlib.pyplot as plt
import pyLDAvis
import pyLDAvis.gensim
texts = [['today', 'cold', 'winter', 'lot', 'snow', 'everywhere'],
['winter', 'snow', 'snowman'],
['summer', 'day', 'sunny', 'lake'],
['sunny', 'garden', 'today'],
['winter', 'snowing', 'today'],
['picnic', 'garden', 'sunny', 'weekend']]
# Create Dictionary
dictionary = corpora.Dictionary(texts)
# Create Corpus
corpus = [dictionary.doc2bow(text) for text in texts]
# Train model
lda_model = gensim.models.ldamodel.LdaModel(corpus=corpus,
id2word=dictionary,
num_topics=3,
random_state=100,
update_every=1,
chunksize=100,
passes=10,
alpha='auto',
per_word_topics=True)
# Visualise topics
pyLDAvis.enable_notebook()
plot = pyLDAvis.gensim.prepare(lda_model, corpus, dictionary)
plot
这是一个应该是什么样子的示例https://nbviewer.jupyter.org/github/bmabey/hacker_news_topic_modelling/blob/master/HN%20Topic%20Model%20Talk.ipynb
我尝试将本地参数设置为 True 但没有任何区别。 pyLDAvis.enable_notebook(local = True)
我尝试将 output 保存为 html 但它产生了一个空文件。 pyLDAvis.save_html(plot, 'lda.html')
我正在使用 python 3.7.1
有什么建议么?
.pip install pyLDAvis==2.1.2
我也遇到了这个问题,这有帮助。 旧版本的pyLDAvis不能与 Jupyter 或 Colab 一起正常工作。
我遇到了同样的问题,我只是使用这个:
pyLDAvis.save_html(绘图,'vis.html')
因此完整的可视化将作为 html 文件保存在 wd 中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.