总有没有隐藏LDA的INFO输出,因此不打印出LDA的进程,而仅打印我程序的输出? 我想隐藏输出,例如:
2018-07-09 11:52:39,916 : INFO : topic #0 (1.000): 0.052*"animals" +
0.037*"cell" + 0.031*"life" + 0.031*"cells" + 0.028*"cycle" +
0.025*"Animals" + 0.022*"nerve" + 0.022*"organs" + 0.019*"digestion" +
0.019*"animal"
2018-07-09 11:52:39,916 : INFO : topic diff=0.000000, rho=0.140028
2018-07-09 11:52:39,916 : INFO : topic #0 (1.000): 0.052*"animals" +
0.037*"cell" + 0.031*"life"
由于我的程序给出很多输出并多次运行LDA,所以我不想这样做,因此可以更快地复制我的实际输出。我的LDA代码如下所示。
def lda(file): # Runs LDA, finding the best topics
dictionary = corpora.Dictionary(file)
corpus = [dictionary.doc2bow(text) for text in file]
l_d_a = gensim.models.ldamodel.LdaModel
ldamodel = l_d_a(corpus, num_topics=1, id2word=dictionary,
passes=50)
topics = ldamodel.print_topics(num_topics=1, num_words=3)
return topics