Hierarchical-Clustering-in-Machine-Learning
Hierarchical-Clustering-in-Machine-Learning
Hierarchical clustering
What is a Dendrogram?
1. Agglomerative Clustering
2. Divisive clustering
Algorithm :
for i=1 to N:
for j=1 to i:
repeat
import numpy as np
clustering = AgglomerativeClustering(n_clusters=2).fit(X)
Output :
[1, 1, 1, 0, 0, 0]
Algorithm :
the cluster is split using a flat clustering method eg. K-Means etc
repeat
1. Min Distance: Find the minimum distance between any two points of
the cluster.
2. Max Distance: Find the maximum distance between any two points
of the cluster.
3. Group Average: Find the average distance between every two points
of the clusters.
4. Ward’s Method: The similarity of two clusters is based on the
increase in squared error when two clusters are merged.
Implementations code
import numpy as np
Z = linkage(X, 'ward')
# Plot dendrogram
dendrogram(Z)
plt.xlabel('Data point')
plt.ylabel('Distance')
plt.show()
Output: