Why can k-medoids work with arbitrary distance metrics while k-means cannot?

Quick Overview

Explain why k-medoids can cluster data with any dissimilarity measure while k-means depends on squared Euclidean distance. Tests whether you understand what each center update minimizes, why the cost keeps falling, and what the medoid search costs in compute and memory.

Why can k-medoids work with arbitrary distance metrics while k-means cannot?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

Why can k-medoids work with arbitrary distance metrics while k-means cannot? Both algorithms alternate between assigning each point to its nearest center and updating the centers. Explain what in the update step lets one of them run with any dissimilarity measure and ties the other to a specific distance. ```hint Look at the update step For a fixed cluster, ask which point minimizes the total distance to the members, and for which distance functions the arithmetic mean is that point. ``` ```hint What a center is allowed to be Compare what k-medoids requires of a center with what k-means requires, and what each one needs to compute to update it. ``` ### What a Strong Answer Covers - Which objective the k-means mean update minimizes, and for which distances that holds. - What happens to the cost and to convergence when the mean update is paired with another distance, and what happens with data that has no mean. - Why the medoid update needs only pairwise dissimilarities and still lowers the cost at every accepted step. - The compute and memory price of searching over candidate medoids. ### Follow-up Questions - If you need clusters under cosine similarity, how could you adapt k-means instead of switching to k-medoids? - How does the PAM swap step scale with the number of points, and how do CLARA or CLARANS make k-medoids usable on large datasets? - How does k-medians differ from k-medoids when the distance is L1? - Why is k-medoids less sensitive to outliers than k-means?

Overview: Explain why k-medoids can cluster data with any dissimilarity measure while k-means depends on squared Euclidean distance. Tests whether you understand what each center update minimizes, why the cost keeps falling, and what the medoid search costs in compute and memory.

General logo
General
Nov 24, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

Why can k-medoids work with arbitrary distance metrics while k-means cannot?

Both algorithms alternate between assigning each point to its nearest center and updating the centers. Explain what in the update step lets one of them run with any dissimilarity measure and ties the other to a specific distance.

What a Strong Answer Covers Guidance

  • Which objective the k-means mean update minimizes, and for which distances that holds.
  • What happens to the cost and to convergence when the mean update is paired with another distance, and what happens with data that has no mean.
  • Why the medoid update needs only pairwise dissimilarities and still lowers the cost at every accepted step.
  • The compute and memory price of searching over candidate medoids.

Follow-up Questions Guidance

  • If you need clusters under cosine similarity, how could you adapt k-means instead of switching to k-medoids?
  • How does the PAM swap step scale with the number of points, and how do CLARA or CLARANS make k-medoids usable on large datasets?
  • How does k-medians differ from k-medoids when the distance is L1?
  • Why is k-medoids less sensitive to outliers than k-means?