Clustering · Machine Learning

K-medoids

1. Difference from K-means

Centroid must be a real data point (medoid), not a mean. Robust to outliers; works with any distance (strings, graphs), not just Euclidean.

2. PAM Algorithm (sketch)

pick k medoids; assign all points to nearest medoid
for each medoid m and non-medoid o: try swap m↔o, keep if total cost drops
repeat till no improving swap

Cost = sum of distances to medoid (use L1L₁ or domain distance for robustness).

3. K-means vs K-medoids

K-means K-medoids
Center mean (may be unreal) real point
Outlier drags mean badly mild effect
Distance Euclidean mostly any
Speed O(nkd)O(nkd) fast O(k(n−k)2)O(k(n-k)²) slow (use CLARA for big nn)

4. When To Use

Small/medium nn with outliers or non-Euclidean distances (e.g. cluster customers by edit distance, facilities location).

5. Exam Points

  • Medoid vs mean + robustness — 5 marks, very frequent.
  • PAM swap idea — 3-5 marks, frequent.
  • Complexity tradeoff — 2 marks.
AI LearningWeb Platform

Coursify — Personal AI Course Generator

Struggling with a difficult subject or concept? Turn any engineering topic into a structured course with interactive lessons, quizzes, and research-backed explanations.

← All Machine Learning modules