Clustering: Distances, Dendrograms, Partitions and What the Output Does Not Prove

What clustering is for

Clustering is an unsupervised method: the data arrive without a response variable, and the task is to partition observations into groups that are more similar within a group than between groups.


That makes it structurally different from the regression and classification methods it is often filed beside.


A logistic regression is told which observations are cases and learns a rule that reproduces those labels; a clustering algorithm is told nothing and proposes labels of its own.


The practical consequence is that there is no held-out accuracy to appeal to. A clustering is judged by whether its groups are compact, separated, stable under perturbation and interpretable in the subject area, and those criteria can disagree with one another.


A second consequence is that the algorithm will always return an answer. Run a partitioning method asking for four groups on data drawn from a single homogeneous population and it will hand back four groups.


Nothing in the output announces that the structure is an artefact, which is why the question 'are these clusters real?' has to be answered outside the algorithm.

Distance is a modelling choice, and so is scale

Many common clustering methods, including k-means and hierarchical clustering, depend on a distance or dissimilarity; model-based methods instead define groups through a probabilistic model.


With Euclidean distance, squared coordinate differences are added. A variable with a much larger typical numerical spread can dominate distances, regardless of which variable is more informative.


Suppose one variable ranges from 0 to 1 and another from 0 to 1,000. Their maximum possible squared coordinate contributions are 1 and 106, respectively, so the second variable has the potential to dominate Euclidean distances.


Whether it actually dominates the distance matrix depends on the variables' distributions and realized pairwise differences; when its typical numerical spread is much larger, standardization may prevent its units from overwhelming the other variable.


Standardizing each variable, usually by subtracting its mean and dividing by its standard deviation, puts the variables on a common footing so that each contributes comparably.


Standardizing is a decision, not a routine cleaning step: it declares that a one-standard-deviation change in each variable is equally important.


If one variable is genuinely more meaningful, or if the variables are already in the same physical units and their relative spreads are themselves informative, rescaling can erase the very structure of interest.


Related choices matter for the same reason. Manhattan distance downweights large single-variable discrepancies compared with Euclidean distance, and correlation-based dissimilarity groups observations with similar profiles regardless of overall level.

Reading the two common families of output

Hierarchical clustering produces a dendrogram. Observations begin as singletons and are merged one pair at a time; the height at which two groups join is the dissimilarity between them under the chosen linkage.


Cutting the tree at a height yields a partition, and the number of groups follows from where the cut is placed. Linkage defines the distance between groups and changes the shape of the result:


  • Single linkage uses the closest pair across two groups. It can follow elongated or curved shapes, but it chains: a few intermediate points bridging two dense regions pull them together, often producing one large group that absorbs observations one at a time.
  • Complete linkage uses the farthest pair, favouring compact, roughly spherical groups of similar diameter, and can split an elongated true group in two.
  • Average linkage uses the mean of all between-group pairwise distances. For the same two groups, this mean lies between the closest-pair and farthest-pair distances.
  • Ward's method instead merges the pair with the smallest increase in within-cluster sum of squares under squared Euclidean geometry. This criterion is not a pairwise-distance average; it tends to favour compact, similarly sized groups.


Partitioning methods such as k-means require the number of groups in advance and iterate between assigning each point to the nearest centre and recomputing the centres.


Each iteration cannot increase the within-cluster sum of squares, so the algorithm converges - but to a local optimum that depends on the starting centres, which is why several random starts are used.


Because centres are means and assignment uses squared Euclidean distance, k-means implicitly prefers roughly spherical groups of comparable spread and is sensitive to outliers.

Judging a clustering

The within-cluster sum of squares cannot be used on its own to choose the number of groups: its minimum possible value is non-increasing as k increases, because any partition can be refined without raising its objective.


This guarantee concerns the global minimum; independently fitted k-means runs can violate that ordering when they reach different local optima.


The global minimum reaches zero by k = n, when every observation is its own cluster. A silhouette measures separation as well as compactness.


For an observation i, let a(i) be its mean distance to the other members of its own cluster and b(i) the smallest mean distance to the members of any other cluster. The silhouette is


s(i) = (b(i) - a(i)) divided by the larger of a(i) and b(i),


which lies between -1 and 1. Values near 1 mean the observation is much closer to its own group than to the nearest alternative; values near 0 mean it sits on a boundary; negative values mean it would be better placed elsewhere.


Worked example. Suppose an observation has a mean distance of 1.8 to the other members of its cluster and a mean distance of 4.5 to the members of the nearest other cluster.


Then b exceeds a, so the denominator is 4.5, and s = (4.5 - 1.8) / 4.5 = 0.600. That is a comfortable but not emphatic value.


Note what it does not establish: a high average silhouette shows the proposed partition is internally coherent under the chosen distance and scaling, not that the groups correspond to real populations. Changing the scaling changes every distance and can change the silhouette substantially.

Common misconceptions

  • Clusters found are proposals, not discoveries. Report them as a summary of the data under stated choices, and check stability by resampling or by perturbing the distance and linkage.
  • The number of groups is not read off a single criterion. Silhouette, gap-type statistics, the shape of the sum-of-squares curve and subject knowledge should be weighed together.
  • Standardizing is not always right, and failing to standardize is not always wrong. State the choice and its justification.

A hospital data set records six laboratory measurements for each of 900 patients, with no outcome variable recorded. An analyst runs a clustering algorithm. What is the goal of that analysis?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

In this sample, annual income has a standard deviation of $12,000 and age has a standard deviation of 9 years. k-means uses Euclidean distances on these raw variables without standardizing them. Why would raw-distance k-means be driven mainly by income?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

The same standardized data are clustered twice. The complete-linkage dendrogram shows two balanced groups joining at a large height. The single-linkage dendrogram instead grows one large group that absorbs observations almost one at a time at steadily increasing heights. What does the single-linkage pattern most likely indicate?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors