【问题标题】:How to get list of words for each topic in pyLDAvis如何获取pyLDAvis中每个主题的单词列表
【发布时间】:2018-12-04 20:45:06
【问题描述】:

我是使用 pyLDAvis 的新手。我一直在查看文档,但似乎找不到为我的模型的每个主题获取一组单词的方法。我有 20 个主题,我想为每个主题获得前 20 个左右的单词。有没有人有办法获取这些数据?

【问题讨论】:

  • 到目前为止你尝试过什么?请包括代码和回溯。 :)

标签: nlp lda


【解决方案1】:

pyldavis.prepare() 方法生成一个 PreparedData 对象,该对象具有 .topic_info 之类的属性,该对象返回一个带有 logprob 等字词的 DataFrame(请参阅 docs

from pyLDAvis.gensim import prepare
vis = prepare(lda_model, corpus, dictionary, mds='tsne')
vis.topic_info

     Category         Freq       Term        Total  loglift  logprob
term                                                                
2299  Default 2,068,609.00      order 2,068,609.00    30.00    30.00
1037  Default   816,951.00      drink   816,951.00    29.00    29.00
2778  Default   565,075.00     review   565,075.00    28.00    28.00

【讨论】:

    猜你喜欢
    • 2021-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多