pyLDAvis基于gensim的LDA模型可视化

import gensim
from gensim import models
import pyLDAvis.gensim


def lda_vis():
    dictionary = gensim.corpora.Dictionary.load('lda.dict')
    corpus = gensim.corpora.MmCorpus('lda.mm')
    lda = models.ldamodel.LdaModel.load('lda.lda')
    vis = pyLDAvis.gensim.prepare(lda, corpus, dictionary)
    pyLDAvis.save_html(vis, 'lda.html')
    return 0


if __name__ == '__main__':
    lda_vis()

你可能感兴趣的:(自然语言处理)