簡體   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)

這是一個非常簡單的可視化,但是當我運行 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'

不幸的是,我在網上搜索了有關此錯誤的信息。 但是,如果我單擊 .ccs 鏈接,我仍然可以查看此 css 文件。
我什至將顯示保存為 HTML 文件,但它是一個空白頁面(由於某些原因未呈現內容)

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

嘗試將pyLDAvis的版本指定為2.1.2

!pip install pyLDAvis==2.1.2

並使用 pyLDAvis.display() 而不是 pyLDAvis.show()

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

這解決了我機器上的同樣問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM