Concepts / Linkage-Based Clustering

Linkage-Based Clustering

Clustering is an unsupervised organization problem rather than a labeled prediction problem.

  • Programming
Interactive lab

Try it: Linkage-Based Clustering

How agglomerative clustering starts from singletons and repeatedly merges the two closest clusters under single (min), complete (max) or average linkage, building a dendrogram until a stopping rule (k clusters or distance threshold r) says stop.

How it works

  1. Start with every point in its own cluster and compute the distance matrix.
  2. Cluster distance: single = closest pair of members (minimum), complete = farthest pair (max linkage), average = mean over all pairs.
  3. Find the closest pair of current clusters (ties go to the pair listed first) and merge them; the cluster count drops by one.
  4. Update the new cluster's row of the distance matrix and record the merge height in the dendrogram.
  5. Stop when k clusters remain, or when every between-cluster distance is larger than r.

Default run (12 steps): 8 points, each its own cluster. Single linkage; stop when 3 clusters remain. … Done: 3 clusters — {A,B,C} {D,E,F,G} {H}.

Simplified: Toy 2-D data (3–10 points) with Euclidean distance. Real hierarchical clustering uses many more points, other distances and faster data structures.

Educational simulation

Loading the simulation…

Why One Grouping May Not Be Enough

Suppose you are given a collection of unlabeled data points and asked to organize them into groups. There may not be one objectively correct answer waiting to be discovered. Clustering is an unsupervised organization problem, so there are no supplied labels whose prediction accuracy can provide a single clear measure of success.

The result depends on what similarity means and on which structural goal the method emphasizes. One approach may emphasize keeping close points together, while another may emphasize preventing far-apart points from sharing a cluster. Both concerns can lead to meaningful but different groupings.

Unlabeled pointsKeep close pointstogetherGrouping APrevent far pointssharingGrouping Bsimilarity goalstructural goal
How can the same unlabeled data support more than one defensible grouping?

Clustering Inputs and Outputs

A clustering task starts with a collection of elements, written as X, together with information about how those elements relate to one another. That information may be a distance function or a similarity function. Some clustering methods also receive a requested number of clusters, k.

The output is an organization of X into groups. A hard clustering assigns each element to a separate group. A soft clustering assigns each element a vector of probabilities describing possible membership in the groups. A dendrogram is another possible output: it represents a hierarchy whose leaves are single-element sets and whose root contains the full domain.

Collection Xdata elementsHard clusteringgroup assignmentDistance orsimilarityrelationshipsSoft clusteringmembership probabilitiesRequested koptional method inputDendrogramhierarchical organizationorganizecompareoptional constraintorganizebuild hierarchy
What data goes into a clustering task, and what forms can the resulting organization take?

The First Clustering Round

Linkage-based clustering builds its result progressively. At the beginning, every data point is placed in its own one-point cluster. The algorithm then examines the current collection of clusters, identifies the closest pair, and merges that pair.

Worked example

A Generated First Round

Consider four generated data points named A, B, C, and D. Assume the closest pair of current clusters is the pair containing A and B.

  1. 1
    Start

    The current clusters are {A}, {B}, {C}, and {D}. Every point begins alone.

  2. 2
    Compare

    The algorithm compares the current clusters using its chosen distance-between-clusters rule.

  3. 3
    Merge

    Because {A} and {B} are the closest current clusters in this generated situation, they become {A, B}.

  4. 4
    Update

    The next round uses {A, B}, {C}, and {D} as the current cluster collection. It does not use only the original one-point clusters.

Result

After this merge, the number of clusters has decreased from four to three.

Four clusters{A} {B} {C} {D}Three clusters{A,B} {C} {D}Two clustersone further mergeOne clusterall points togethermerge closest pairmerge closest pairmerge closest pair
What happens in each round, and why does the number of clusters decrease after every merge?

How Cluster Distance Controls a Merge

A point-to-point distance is not enough for this procedure because the algorithm compares clusters, not just individual points. The point-to-point notion must be extended into a distance between clusters. In each round, the pair with the smallest current cluster distance is selected for merging.

Definition

Single linkage defines the distance between two clusters by finding the closest pair of members, with one member taken from each cluster. That smallest cross-cluster point-to-point distance becomes the distance between the clusters.

Worked example

Finding a Single-Linkage Distance

Let cluster P contain points p1 and p2, and cluster Q contain points q1 and q2. Suppose the four cross-cluster distances are: p1 to q1 is 8, p1 to q2 is 5, p2 to q1 is 3, and p2 to q2 is 7.

  1. 1
    List cross-cluster pairs

    Consider only pairs with one point from P and one point from Q.

  2. 2
    Find the closest pair

    The smallest listed cross-cluster distance is 3, between p2 and q1.

  3. 3
    Assign the cluster distance

    Under single linkage, the distance between P and Q is therefore controlled by the p2-to-q1 pair.

Result

The single-linkage distance between P and Q is the closest cross-cluster distance: the distance between p2 and q1, which is 3 in this generated example.

Cluster Pp1, p2p2 to q1closest cross-cluster pairCluster Qq1, q2member p2member q1
How does single linkage determine the distance between two clusters, and which pair of points controls that distance?

The Chaining Effect

Single linkage can produce an unintuitive result because one close connection is enough to make two clusters appear close. After a merge, a point in the growing cluster may be close to a point in another cluster, even if many other points across the two clusters are far apart.

Repeated local connections can therefore join a long sequence of points. The points at the two distant ends of the sequence may not resemble one another directly, yet single linkage can connect them through intermediate points. This is called the chain effect in the supplied material.

Left groupbefore mergingOne chain clusternearby links connect thesequenceRight groupbefore merginglocal close connectionrepeated local connections
How can a long chain of nearby points cause single linkage to join groups that appear visually separate?

Defining the Algorithm Clearly

A description such as “repeatedly merge close clusters” is incomplete. Two design choices determine the behavior of a linkage-based clustering algorithm: how distance between clusters is measured, and when the merging process stops.

Linkage-basedalgorithmCluster distance rulehow clusters are comparedStopping rulewhen merging endsspecifiesspecifies
Which two choices must be specified to define a linkage-based clustering algorithm clearly?
ChoiceQuestion it answersSingle-linkage lesson
Cluster distance ruleHow close are two current clusters?Use the closest member-to-member pair
Stopping ruleWhen should merging end?Specify the point at which the progressive process stops

Both choices are needed for a clear description of the algorithm.

  • Common mistake

    Assuming that clustering must discover one uniquely correct grouping.

    What it looks like

    Treating the output as correct only when it matches a single expected partition.

    Why it fails

    Clustering is unsupervised, and different notions of similarity or structural goals can support different meaningful groupings.

    Do this instead

    State what similarity means and what structural goal the method is emphasizing.

  • Common mistake

    Comparing only the original individual points after the first merge.

    What it looks like

    After merging two points, continuing to select the next pair from the original one-point list.

    Why it fails

    The next decision must use the new collection of current clusters.

    Do this instead

    Reconsider the cluster collection after every merge.

  • Common mistake

    Assuming single linkage requires every cross-cluster pair to be close.

    What it looks like

    Rejecting a merge because most pairs across two clusters are far apart.

    Why it fails

    Single linkage uses the closest cross-cluster pair; one close connection can control the cluster distance.

    Do this instead

    Search for the minimum member-to-member distance between the two clusters.

  • Common mistake

    Describing the method without a stopping rule.

    What it looks like

    Saying only that the algorithm repeatedly merges the closest clusters.

    Why it fails

    The distance rule and the point at which merging stops both determine the defined procedure.

    Do this instead

    Specify both the cluster-distance rule and the stopping rule.

Practice the Merge Process

EASY

Imagine that the current clusters are {A}, {B}, and {C}. Under single linkage, the closest cross-cluster pair between {A} and {B} is closer than the closest cross-cluster pair between either of those clusters and {C}. What happens next, and how many clusters remain?

Hints
  • The algorithm selects the closest pair of current clusters.
  • A merge replaces two clusters with one cluster.
Worked example

Practice Result

Starting with {A}, {B}, and {C}, suppose {A} and {B} have the smallest single-linkage distance.

  1. 1
    Select

    Choose {A} and {B}, because their current cluster distance is the smallest.

  2. 2
    Merge

    Replace the two selected clusters with {A, B}.

  3. 3
    Count

    The current collection is now {A, B} and {C}, so there are two clusters.

Result

The next state contains two clusters: {A, B} and {C}.

What to Remember

  1. 1
    Clustering is an unsupervised organization problem, so the same data can support multiple meaningful groupings.
  2. 2
    A clustering task takes elements and relationship information such as distances or similarities, and it produces groups, probabilities, or a hierarchy.
  3. 3
    Linkage-based clustering starts with every point in its own cluster and repeatedly merges the closest current clusters.
  4. 4
    Every merge replaces two clusters with one, so the number of clusters decreases after each round.
  5. 5
    Single linkage uses the closest pair of members across two clusters, which can create a chain connecting globally dissimilar ends.
  6. 6
    A complete algorithm description must specify both how cluster distance is measured and when merging stops.

At a glance

  • Clustering does not always have one uniquely correct answer because similarity and structural goals can be defined in different ways.
  • Linkage-based clustering begins with one cluster per point and builds larger clusters through successive merges.
  • The closest pair of current clusters determines each merge, so the algorithm must reconsider the cluster collection after every round.
  • Single linkage defines cluster distance using the closest cross-cluster pair, making it vulnerable to chaining effects.
  • The two essential design choices are the cluster-distance rule and the stopping rule.

Related concepts

More concepts starting with L