# Hierarchical Clustering

last updated 23-Jun-2021

## Introduction

Produces a set of nested clusters organized as a hierarchical tree

Can be visualized as a dendrogram

• A tree like diagram that records the sequences of merges or splits Do not have to assume any particular number of clusters

• Any desired number of clusters can be obtained by ‘cutting’ the dendrogram at the proper level

They may correspond to meaningful taxonomies

• Example in biological sciences (e.g., animal kingdom, phylogeny reconstruction, …)

Two main types of hierarchical clustering

Agglomerative:

• At each step, merge the closest pair of clusters until only one cluster (or k clusters) left

Divisive:

• At each step, split a cluster until each cluster contains an individual point (or there are k clusters)

Traditional hierarchical algorithms use a similarity or distance matrix

• Merge or split one cluster at a time

## Agglomerative Clustering Algorithm

Most popular hierarchical clustering technique

Basic algorithm is straightforward

1. Compute the proximity matrix
2. Let each data point be a cluster
3. Repeat
1. Merge the two closest clusters
2. Update the proximity matrix
4. Until only a single cluster remains

Key operation is the computation of the proximity of two clusters.

Different approaches to defining the distance between clusters distinguish the different algorithms

Starting point After some merging we can have Intermediate situation--we want to merge the two closet clusters, C2 and C5, then update the proximity matrix. How to update the proximity matrix? ### Possible definitions of inter-cluster similarity

MIN MAX Group Average Distance Between Centroids Other methods driven by an objective function: e.g., Ward’s Method uses squared error

Proximity of two clusters is based on the two closest points in the different clusters. Determined by one pair of points, i.e., by one link in the proximity graph  ### Strength of MIN

Handling of non-elliptical shapes ### Limitation Proximity of two clusters is based on the two farthest points of the closest clusters. Determined by one pair of points, i.e., by one link in the proximity graph.  Strength: less susceptible to noise and outliers Limitation of MAX

• Tends to break large clusters
• Biased towards globular clusters ## Group Average

Proximity of two clusters is the average of pairwise proximity between points in the two clusters. Need to use average connectivity for scalability since total proximity favors large clusters The above is actually Ward's Method.  Below is the average This is a compromise between Single and Complete Link

Strengths: Less susceptible to noise and outliers

Limitations: Biased towards globular clusters

## Ward's Method

Similarity of two clusters is based on the increase in squared error when two clusters are merged

• Similar to group average if distance between points is distance squared

Less susceptible to noise and outliers

Biased towards globular clusters

Hierarchical analog of K-means

• Can be used to initialize K-means ## Performance of hierarchical clusters

O(N2) space since it uses the proximity matrix, where N is the number of points.

O(N3) time in many cases

• There are N steps and at each step the size, N2, proximity matrix must be updated and searched
• Complexity can be reduced to O(N2 log(N) ) time with some cleverness

Once a decision is made to combine two clusters, it cannot be undone.

No global objective function is directly minimized

Different schemes have problems with one or more of the following:

• Sensitivity to noise and outliers
• Difficulty handling clusters of different sizes and non-globular shapes
• Breaking large clusters