Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| from sklearn.feature_extraction.text import TfidfVectorizer, CountVectorizer | |
| from sklearn.datasets import fetch_20newsgroups | |
| from sklearn.decomposition import NMF, LatentDirichletAllocation | |
| def display_topics(model, feature_names, no_top_words): | |
| for topic_idx, topic in enumerate(model.components_): | |
| print "Topic %d:" % (topic_idx) | |
| print " ".join([feature_names[i] | |
| for i in topic.argsort()[:-no_top_words - 1:-1]]) |