版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/fjssharpsword/article/details/80402037
LDA-python库:https://github.com/lda-project/lda
API参考:https://pythonhosted.org/lda/api.html
构建好doc-word矩阵,就可以直接调用接口,参考如下:
#LDA
def matrix_topic(self,R,K=2):
model = lda.LDA(n_topics=K, n_iter=100, random_state=0)
model.fit(R)
return model.doc_topic_,model.topic_word_
具体代码可在github上深入。