Skip to content

Instantly share code, notes, and snippets.

@aneesha
Created September 1, 2016 00:33
Show Gist options
  • Save aneesha/440f3d104415c6ae21851a062f3880d8 to your computer and use it in GitHub Desktop.
Save aneesha/440f3d104415c6ae21851a062f3880d8 to your computer and use it in GitHub Desktop.
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]])
no_top_words = 10
display_topics(nmf, tfidf_feature_names, no_top_words)
display_topics(lda, tf_feature_names, no_top_words)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment