1. 程式人生 > >【LDA學習系列】LDA-Python庫

【LDA學習系列】LDA-Python庫

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上深入。