Skip to content

Instantly share code, notes, and snippets.

@mlai-demo
Last active January 19, 2020 22:23
Show Gist options
  • Save mlai-demo/3d8cf1c92240ea0b6c1b2486dda6d9ce to your computer and use it in GitHub Desktop.
Save mlai-demo/3d8cf1c92240ea0b6c1b2486dda6d9ce to your computer and use it in GitHub Desktop.
create text topics using NMF
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