HelloI want to implement hierarchical clustering using basic code

5 views (last 30 days)
Hello I want to implement hierarchical clustering using basic code and not using (pdist,linkage) functions. Thanks for your reply.

Answers (1)

Prasanna
Prasanna on 5 Dec 2024
Hi Ali,
To implement hierarchical clustering without using inbuild MATLAB functions, you can perform the following:
  • 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.
For more information regarding hierarchical clustering, refer the following documentations:
Hope this helps!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!