我正在尝试使用pyLDAvis可视化lda模型。正在获取AttributeError:“ LdaModel”对象在计算
时没有属性“ components_”ldamodel.components_ / ldamodel.components_.sum(axis = 1)[:,无]
代码:
import gensim from gensim
import corpora
dictionary = corpora.Dictionary(doc_cleaned)
doc_term_matrix = [dictionary.doc2bow(doc) for doc in doc_cleaned]
Lda = gensim.models.ldamodel.LdaModel
ldamodel = Lda(doc_term_matrix, num_topics=27, id2word = dictionary, passes=50, minimum_probability=0)
print(ldamodel.print_topics(num_topics=27, num_words=3))
ldamodel.show_topics()
topic_term_dists = ldamodel.components_ / ldamodel.components_.sum(axis=1)[:, None]