How to print the LDA topics models from gensim? Python

后端 未结 10 1680
北荒
北荒 2020-12-04 13:42

Using gensim I was able to extract topics from a set of documents in LSA but how do I access the topics generated from the LDA models?

When printing the

10条回答
  •  北荒
    北荒 (楼主)
    2020-12-04 14:07

    ****This code works fine but I want to know the topic name instead of Topic: 0 and Topic:1, How do i know which topic this word comes in**?** 
    
    
    
    for index, topic in lda_model.show_topics(formatted=False, num_words= 30):
            print('Topic: {} \nWords: {}'.format(idx, [w[0] for w in topic]))
    
    Topic: 0 
    Words: ['associate', 'incident', 'time', 'task', 'pain', 'amcare', 'work', 'ppe', 'train', 'proper', 'report', 'standard', 'pmv', 'level', 'perform', 'wear', 'date', 'factor', 'overtime', 'location', 'area', 'yes', 'new', 'treatment', 'start', 'stretch', 'assign', 'condition', 'participate', 'environmental']
    Topic: 1 
    Words: ['work', 'associate', 'cage', 'aid', 'shift', 'leave', 'area', 'eye', 'incident', 'aider', 'hit', 'pit', 'manager', 'return', 'start', 'continue', 'pick', 'call', 'come', 'right', 'take', 'report', 'lead', 'break', 'paramedic', 'receive', 'get', 'inform', 'room', 'head']
    

提交回复
热议问题