Hierarchical Clustering

Bottom-up clustering that builds a hierarchy of clusters

What is Hierarchical Clustering?

Hierarchical clustering creates a tree of clusters called a dendrogram. It can be either agglomerative (bottom-up) or divisive (top-down). The agglomerative approach starts with each point as its own cluster and merges the closest pairs iteratively.

Linkage Criteria:

  • Ward: Minimizes within-cluster variance
  • Complete: Maximum distance between clusters
  • Average: Average distance between all pairs
  • Single: Minimum distance between clusters

Advantages:

  • No need to specify K in advance
  • Dendrogram provides complete hierarchy
  • Can find clusters at multiple scales
  • Works with any distance metric
  • Deterministic (no random initialization)

Parameters

Distance calculation method
Fewer samples for clearer dendrogram

Cluster Visualization

Results

Run clustering to see results

Understanding Hierarchical Clustering

When to Use

  • Need to explore different granularities
  • Hierarchical structure in data
  • Small to medium datasets
  • Unknown optimal number of clusters
  • Need deterministic results
  • Taxonomies and phylogenetic trees

Limitations

  • O(n³) time complexity
  • O(n²) space complexity
  • Cannot undo merges (greedy)
  • Sensitive to noise and outliers
  • Not suitable for large datasets
  • Difficult to interpret for many clusters

Linkage Methods Comparison

Ward: Best for spherical, similarly-sized clusters

Complete: Compact clusters, sensitive to outliers

Average: Balanced approach, less sensitive to outliers

Single: Can handle elongated clusters, prone to chaining