简体   繁体   English

pyLDAvis.show function 要求在 Jupyter 笔记本中缺少.css 文件

[英]pyLDAvis .show function asks for missing .css file in Jupyter notebook

import pyLDAvis
import pyLDAvis.gensim
pyLDAvis.enable_notebook()
LDAvis_prepared = pyLDAvis.gensim.prepare(lda_model, bow_corpus, dictionary)
pyLDAvis.show(LDAvis_prepared)

This is a very simple visualization however, when I ran the show command, an error popped up:这是一个非常简单的可视化,但是当我运行 show 命令时,会弹出一个错误:

FileNotFoundError                         Traceback (most recent call last)
<ipython-input-152-64a947f66dc2> in <module>
----> 1 pyLDAvis.show(LDAvis_prepared)

/opt/anaconda3/lib/python3.7/site-packages/pyLDAvis/_display.py in show(data, ip, port, n_retries, local, open_browser, http_server, **kwargs)
    262                  open(urls.LDAVIS_LOCAL, 'r').read()],
    263                  '/LDAvis.css': ["text/css",
--> 264                                  open(urls.LDAVIS_CSS_URL, 'r').read()],
    265                  '/d3.js': ["text/javascript",
    266                             open(urls.D3_URL, 'r').read()]}

FileNotFoundError: [Errno 2] No such file or directory: 'https://cdn.rawgit.com/bmabey/pyLDAvis/files/ldavis.v1.0.0.css'

I searched online unfortunately, not much information on this error.不幸的是,我在网上搜索了有关此错误的信息。 However if I clicked on the.ccs link, I could still view this css file.但是,如果我单击 .ccs 链接,我仍然可以查看此 css 文件。
I even saved the display as a HTML file but it's a blank page (content is not rendered for some reasons)我什至将显示保存为 HTML 文件,但它是一个空白页面(由于某些原因未呈现内容)

pyLDAvis.save_html(LDAvis_prepared,'sss.html')

Try to specify the version of pyLDAvis to 2.1.2尝试将pyLDAvis的版本指定为2.1.2

!pip install pyLDAvis==2.1.2

and use pyLDAvis.display() instead of pyLDAvis.show()并使用 pyLDAvis.display() 而不是 pyLDAvis.show()

topic_data =  pyLDAvis.gensim.prepare(ldamodel, doc_term_matrix, dictionary, mds = 'pcoa', sort_topics=True)
pyLDAvis.display(topic_data)

This solved the same problem on my machine.这解决了我机器上的同样问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM