Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print ("Clustering result by K-means")
- # km.cluster_centers_ denotes the importances of each items in centroid.
- # We need to sort it in decreasing-order and get the top k items.
- order_centroids = km.cluster_centers_.argsort()[:, ::-1]
- Cluster_keywords_summary = {}
- for i in range(num_clusters):
- print ("Cluster " + str(i) + " words: ", end='')
- Cluster_keywords_summary[i] = []
- for ind in order_centroids[i, :5]: #replace 5 with n words per cluster
- Cluster_keywords_summary[i].append(vocab_frame_dict[tf_selected_words[ind]])
- print (vocab_frame_dict[tf_selected_words[ind]] + ",", end='')
- cluster_NBA = frame.loc[i]['Name'].values
- print("\n", ", ".join(cluster_NBA), "\n")
Add Comment
Please, Sign In to add comment