Last active
July 23, 2017 13:53
-
-
Save aneesha/146e3d030ca7cbced9d94c34d87e5714 to your computer and use it in GitHub Desktop.
This file contains 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 display_topics(H, W, feature_names, documents, no_top_words, no_top_documents): | |
for topic_idx, topic in enumerate(H): | |
print "Topic %d:" % (topic_idx) | |
print " ".join([feature_names[i] | |
for i in topic.argsort()[:-no_top_words - 1:-1]]) | |
top_doc_indices = np.argsort( W[:,topic_idx] )[::-1][0:no_top_documents] | |
for doc_index in top_doc_indices: | |
print documents[doc_index] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment