Skip to content
PostMachine Learning / Lecture

ML-Distance Measure

2024-12-24
Back to Blog

ML-Cluster Distance Measure ​

Measuring the distance of two clusters

A few ways to measure the distance of two clusters.

Results in different variations of the algorithm.

  • Single link
  • Complete link
  • Average link
  • Centroids
  • Definition: Distance between two clusters is defined as the shortest distance between any two points in the clusters.
  • Formula:dsingle(A,B)=min{d(x,y):x∈A,y∈B}
  • Characteristics:
    • Forms "chain-like" clusters, suitable for finding non-convex shapes.
    • Disadvantage: Sensitive to noise and outliers.
  • Use Case: Suitable for datasets where the clusters are non-convex.

  • Definition: Distance between two clusters is defined as the longest distance between any two points in the clusters.
  • Formula:dcomplete(A,B)=max{d(x,y):x∈A,y∈B}
  • Characteristics:
    • Creates compact clusters with limited spread.
    • Disadvantage: May over-split clusters; not suitable for complex distributions.
  • Use Case: Preferred when tight clusters are required.

  • Definition: Distance between two clusters is defined as the average of all pairwise distances between points in the two clusters.
  • Formula:daverage(A,B)=1|A|⋅|B|∑x∈A∑y∈Bd(x,y)
  • Characteristics:
    • Balances single link and complete link approaches.
    • Robust to noise compared to single link but less than complete link.
  • Use Case: Suitable for evenly distributed data and balanced clustering.

Centroids ​

  • Definition: Distance between two clusters is defined as the distance between their centroids (average points).
  • Formula:dcentroids(A,B)=||cA−cB||Where cA and cB are the centroids of clusters A and B.
  • Characteristics:
    • Simple to compute but may cause "reversal" (merged clusters may separate due to centroid movement).
    • Disadvantage: Not suitable for complex shapes.
  • Use Case: Effective for spherical or isotropic clusters.

Comparison Table ​

MethodAdvantageDisadvantageSuitable Use Case
Single LinkDetects non-convex clustersSensitive to noise and outliersChain-like, non-convex clusters
Complete LinkCreates tight clustersStruggles with complex distributionsCompact, tight clustering
Average LinkBalances between single and completeHigher computational costBalanced clustering
CentroidsComputationally efficientNot suitable for irregular clustersSpherical, fast computation

Time complexity ​

All the algorithms are at least O(n2). n is the number of data points.

  • Single link can be done in O(n2).
  • Complete and average links can be done in O(n2logn).
  • Due the complexity, hard to use for large data sets.
    • Sampling
    • Scale-up methods (e.g., BIRCH).