Last active
January 19, 2020 22:23
-
-
Save mlai-demo/3d8cf1c92240ea0b6c1b2486dda6d9ce to your computer and use it in GitHub Desktop.
create text topics using NMF
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
num_top_words = 10 | |
topic_words_nmf = [] | |
text_topic_nmf = deco_nmf.fit_transform(tm_sparse) | |
for topic in deco_nmf.components_: | |
word_idx = np.argsort(topic)[::-1][0:num_top_words] | |
topic_words_nmf.append([vocab[i] for i in word_idx]) | |
for t in range(len(topic_words_nmf)): | |
print("NMF Topic {}: {}".format(t, ' '.join(topic_words_nmf[t][:10]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment