Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. tfidf_matrix = tfidf_vectorizer.fit_transform(data)
  2.  
  3. from sklearn.metrics.pairwise import cosine_similarity
  4. dist = 1 - cosine_similarity(tfidf_matrix)
  5.  
  6. from scipy.cluster.hierarchy import ward, dendrogram, fcluster
  7.  
  8. linkage_matrix = ward(dist)
  9.  
  10. #Lowest level clustering
  11. clusters = fcluster(Z = linkage_matrix,t = 10, criterion='maxclust')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement