【发布时间】:2019-08-12 07:35:16
【问题描述】:
我正在使用带有 gensim 的 LDA 进行主题建模。我的数据有 23 个文档,我希望每个文档都有单独的主题/单词,但 gensim 正在为整个文档集提供主题。如何为单个文档获取它?
dictionary = corpora.Dictionary(doc_clean)
# Converting list of documents (corpus) into Document Term Matrix using
#dictionary prepared above.
corpus = [dictionary.doc2bow(doc) for doc in doc_clean]
# Creating the object for LDA model using gensim library
Lda = gensim.models.ldamodel.LdaModel
# Running and Trainign LDA model on the document term matrix.
ldamodel = Lda(corpus, num_topics=3, id2word = dictionary, passes=50)
result=ldamodel.print_topics(num_topics=3, num_words=3)
这是我得到的输出:
[(0, '0.011*"plex" + 0.010*"game" + 0.009*"racing"'),
(1, '0.008*"app" + 0.008*"live" + 0.007*"share"'),
(2, '0.015*"device" + 0.009*"file" + 0.008*"movie"')]
【问题讨论】:
标签: python nltk gensim lda topic-modeling