Last active
June 2, 2019 02:25
-
-
Save jetnew/bd9cc4a2f548ea20596d825e682be880 to your computer and use it in GitHub Desktop.
Hierarchical Clustering using scikit-learn and scipy
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
from sklearn.cluster import AgglomerativeClustering | |
clusters = 3 | |
y_pred = AgglomerativeClustering(n_clusters=clusters).fit_predict(X) | |
from scipy.cluster.hierarchy import linkage, fcluster, dendrogram | |
clusters=5 | |
cls = linkage(X, method='ward') | |
y_pred = fcluster(cls, t=clusters, criterion='maxclust') | |
dendrogram(cls) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment