- Prepare the input data as a matrix where each row is an observation and column a feature.
- Compute the pairwise distance(Euclidean or ward) between each pair of observations and store these distances in a symmetric distance matrix.
- Initialize each observation as its own cluster and identify the pair of clusters with the smallest distance between them. Combine the two closest clusters into a single cluster.
- Recalculate the distances between the new cluster and all other clusters using the Ward linkage method (or another linkage criterion). Recalculate the distances between the new cluster and all other clusters using the Ward linkage method (or another linkage criterion).
- Continue the process of finding the closest clusters, merging them, and updating distances until all observations are merged into a single cluster.
- Further, you can visualize the clustering process using a dendrogram.
- Hierarchical clustering: https://www.mathworks.com/help/stats/hierarchical-clustering.html
- Clustering using WPGMA and UPGMA methods: https://www.mathworks.com/matlabcentral/fileexchange/56844-hierarchical-clustering