【问题标题】:Printing topic distribution after LDA using gensim使用 gensim 在 LDA 之后打印主题分布
【发布时间】:2016-10-29 20:26:36
【问题描述】:

我制作了一个示例程序,用于在使用 gensim 进行 LDA 后获取每个文档的主题分布

documents = ["Apple is releasing a new product", 
             "Amazon sells many things",
             "Microsoft announces Nokia acquisition"]   

stoplist=["is","are","am","were","a","me","I"]

texts = [[word for word in document.lower().split() if word not in stoplist] for document in documents]
dictionary = gensim.corpora.Dictionary(texts)
corpus = [dictionary.doc2bow(text) for text in texts]

lda = gensim.models.ldamodel.LdaModel(corpus=corpus, id2word=dictionary, num_topics=2, update_every=1, chunksize=10000, passes=1)
lda.print_topics(2)

但是程序没有打印任何东西..需要任何更改吗?

【问题讨论】:

    标签: python lda gensim


    【解决方案1】:

    如果有人需要,找到答案.. logger 之前必须使用

    logging.basicConfig(format='%(message)s', level=logging.INFO)
    

    【讨论】:

      猜你喜欢
      • 2013-06-23
      • 2017-02-19
      • 2013-07-13
      • 2015-06-27
      • 2023-04-06
      • 2017-12-31
      • 2020-12-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多