Why is Ward linkage only valid with Euclidean distance?

Quick Overview

Asks why Ward linkage in hierarchical clustering requires Euclidean distance. Tests the sum-of-squares merge cost, the role of centroids and the variance decomposition, how the Lance-Williams update behaves with other metrics, and what to use when the data calls for cosine or Manhattan distance.

Why is Ward linkage only valid with Euclidean distance?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

In agglomerative hierarchical clustering, libraries such as scikit-learn only allow Ward linkage together with Euclidean distance. Why is Ward linkage only valid with Euclidean distance? ```hint Start from the objective Write down what Ward's method minimizes at each merge, then ask which point minimizes a sum of distances under a metric other than squared Euclidean. ``` ```hint The merge formula The closed-form merge cost comes from expanding a squared norm around a mean. Which step of that expansion needs an inner product? ``` ### What a Strong Answer Covers - What Ward's method minimizes at each merge, and the closed-form merge cost - Why that derivation needs squared Euclidean distance (the mean as the minimizer, the sum-of-squares decomposition) - What happens when other dissimilarities are fed into the Lance-Williams update - How common libraries handle it, and what to use for cosine, Manhattan or other metrics ### Follow-up Questions - You have text embeddings compared by cosine similarity. Can you still use Ward, and what would you do to the vectors first? - Why can centroid and median linkage produce inversions in the dendrogram while Ward does not? - Given only a precomputed dissimilarity matrix, how would you check whether it can be embedded in Euclidean space before running Ward? - How does Ward linkage relate to k-means?

Overview: Asks why Ward linkage in hierarchical clustering requires Euclidean distance. Tests the sum-of-squares merge cost, the role of centroids and the variance decomposition, how the Lance-Williams update behaves with other metrics, and what to use when the data calls for cosine or Manhattan distance.

Nov 24, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

In agglomerative hierarchical clustering, libraries such as scikit-learn only allow Ward linkage together with Euclidean distance.

Why is Ward linkage only valid with Euclidean distance?

What a Strong Answer Covers Guidance

  • What Ward's method minimizes at each merge, and the closed-form merge cost
  • Why that derivation needs squared Euclidean distance (the mean as the minimizer, the sum-of-squares decomposition)
  • What happens when other dissimilarities are fed into the Lance-Williams update
  • How common libraries handle it, and what to use for cosine, Manhattan or other metrics

Follow-up Questions Guidance

  • You have text embeddings compared by cosine similarity. Can you still use Ward, and what would you do to the vectors first?
  • Why can centroid and median linkage produce inversions in the dendrogram while Ward does not?
  • Given only a precomputed dissimilarity matrix, how would you check whether it can be embedded in Euclidean space before running Ward?
  • How does Ward linkage relate to k-means?