Created
August 4, 2020 00:50
-
-
Save ShairozS/8a3b8c75966cf9ca5dd7d02c7ea2c229 to your computer and use it in GitHub Desktop.
Retrieve the label of a topic on a trained Gensim LDA model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def topic_label(ldamodel, topicnum): | |
| alltopics = ldamodel.show_topics(formatted=False) | |
| topic = alltopics[topicnum] | |
| topic = dict(topic[1]) | |
| return(max(topic, key=lambda key: topic[key])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment