How the Agglomerative Hierarchical clustering Work?

The working of the AHC algorithm can be explained using the below steps:

  • Step-1: Create each data point as a single cluster. Let’s say there are N data points, so the number of clusters will also be N.
    Hierarchical Clustering in Machine Learning
  • Step-2: Take two closest data points or clusters and merge them to form one cluster. So, there will now be N-1 clusters.
    Hierarchical Clustering in Machine Learning
  • Step-3 : Again, take the two closest clusters and merge them together to form one cluster. There will be N-2 clusters.
    Hierarchical Clustering in Machine Learning
  • Step-4: Repeat Step 3 until only one cluster left. So, we will get the following clusters. Consider the below images:
    Hierarchical Clustering in Machine Learning
    Hierarchical Clustering in Machine Learning
    Hierarchical Clustering in Machine Learning
  • Step-5: Once all the clusters are combined into one big cluster, develop the dendrogram to divide the clusters as per the problem.