0

我正在尝试为我构建的 LDA 模型创建交互式 pyLDAvis 可视化,虽然我能够创建静态可视化,但我正在努力解决以下问题:

  1. 输出与屏幕右上角的“相关性指标”滑块交互的动态视觉效果。当我调整相关性指标时,每个主题的单词、显着性度量等都不会改变。

网页上显示的静态视觉对象的屏幕截图

  1. 在无法通过保存的 html 文件和网页显示交互式视觉效果后,我尝试在 Spyder 上显示视觉效果。我尝试使用以下命令:
In: pyLDAvis.display(vis_data)
Out: <IPython.core.display.HTML object>

In: pyLDAvis.show(vis_data)
Out: FileNotFoundError: [Errno 2] No such file or directory: 'https://cdn.jsdelivr.net/gh/bmabey/pyLDAvis@3.3.1/pyLDAvis/js/ldavis.v1.0.0.css'

下面是我用来创建模型和绘图的代码。如果我能在创建交互式 html 文件或在 IDE(最好是 Spyder)中显示结果方面获得帮助,我将不胜感激。我的python版本是3.8.3。谢谢!

# Calling File Cleanser on a file
fileTextTokenized = FileCleanser(mahabharatatext)
        
# Converting each word into a word-count dictionary format
dictionary = Dictionary(fileTextTokenized)
dictionary.filter_extremes(no_below = 100, no_above = 0.8)

gensim_corpus = [dictionary.doc2bow(word) for word in fileTextTokenized]
temp = dictionary[0]
id2word = dictionary.id2token

# Setting model parameters    
chunksize = 2000
passes = 20
iterations = 400
num_topics = 6

lda_model = LdaModel(
corpus=gensim_corpus,
id2word=id2word,
chunksize=chunksize,
alpha='auto',
eta='auto',
iterations=iterations,
num_topics=num_topics,
passes=passes
)

vis_data = gensimvis.prepare(lda_model, gensim_corpus, dictionary)
vis_data
pyLDAvis.display(vis_data)
pyLDAvis.save_html(vis_data, './FileModel'+ str(num_topics) +'.html')
4

0 回答 0