python - Jupyter notebook 中的 LDA 可视化

标签 python nlp jupyter-notebook data-visualization pyldavis

当使用 pyLDAvis 包如下时,在我的 jupyter notebook 中,

pyLDAvis.enable_notebook()

lda_tfidf = LatentDirichletAllocation(n_components=20, random_state=0)
lda_tfidf.fit(dtm_tfidf)
pyLDAvis.sklearn.prepare(lda_tf, dtm_tf, tf_vectorizer)
结果图自动调整我的 jupyter 笔记本的宽度,使所有其他单元格与边界重叠 - 我试过:
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:95% !important; }</style>"))
没有运气,以及
# Using gensim[![enter image description here][1]][1]
v = pyLDAvis.gensim.prepare(lda_model, doc_term_matrix, dictionary)
pyLDAvis.display(v)
花一些时间搜索文档......似乎没有任何关于这个文档的内容,有没有人之前研究过代码并且可以指出我正确的方向?
似乎没有任何其他帖子,但检查过版本等......没有运气
重叠的图像如下所示:
:overlapimg

最佳答案

您是否尝试过使用 %matplotlib inline ?我有一个类似的代码,显示效果很好。这是我的例子:

%matplotlib inline
vis = pyLDAvis.gensim.prepare(topic_model=lda_model, corpus=corpus, dictionary=dictionary_LDA)
pyLDAvis.enable_notebook()
pyLDAvis.display(vis)
编辑:我在我的 Jupyter Notebook 中确实遇到了同样的问题(重叠用于输出区域)。
通过在调用 pyLDAvis.display 之前更改样式,我设法获得了更好的显示效果:
from IPython.core.display import display, HTML
display(HTML("<style>.container { max-width:100% !important; }</style>"))
display(HTML("<style>.output_result { max-width:100% !important; }</style>"))
display(HTML("<style>.output_area { max-width:100% !important; }</style>"))
display(HTML("<style>.input_area { max-width:100% !important; }</style>"))
特别改变 output_area 和 input_area 并设置最大宽度(不是宽度)

关于python - Jupyter notebook 中的 LDA 可视化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62823331/

相关文章:

parsing - 如何将文本文件转换为麦芽解析器的 CoNLL 格式?

jupyter-notebook - 从 Repo Databricks 中的另一个笔记本运行笔记本

Python请求无法获取cookie

python - 在 Python 中更新 geojson 文件中的值

machine-learning - 使用感知器进行情感分析

jupyter-notebook - 观察 ipywidget slider 的方法不起作用

python - ipywidgets 使用复选框来显示或隐藏其他小部件

python - 如何使用plotly指定子图场景中每个图的颜色

python - 如果特定值后跟另一个特定值,则从数据库中提取数据

python - 用 Python 抓取 Edmunds.com 网站时如何处理读取超时错误?