Guest User

Untitled

a guest
Nov 16th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. print ("Clustering result by K-means")
  2. # km.cluster_centers_ denotes the importances of each items in centroid.
  3. # We need to sort it in decreasing-order and get the top k items.
  4. order_centroids = km.cluster_centers_.argsort()[:, ::-1]
  5.  
  6. Cluster_keywords_summary = {}
  7. for i in range(num_clusters):
  8. print ("Cluster " + str(i) + " words: ", end='')
  9. Cluster_keywords_summary[i] = []
  10. for ind in order_centroids[i, :5]: #replace 5 with n words per cluster
  11. Cluster_keywords_summary[i].append(vocab_frame_dict[tf_selected_words[ind]])
  12. print (vocab_frame_dict[tf_selected_words[ind]] + ",", end='')
  13.  
  14. cluster_NBA = frame.loc[i]['Name'].values
  15. print("\n", ", ".join(cluster_NBA), "\n")
Add Comment
Please, Sign In to add comment