K-Medoids clustering — centers that are real rows
K-Medoids (PAM) does the same assignment loop as K-Means, but the center of a cluster has to be an actual row, called a medoid. The cost is the sum of distances to that row, not to a coordinate-wise mean. A single wild value cannot drag the center, because the center is whichever member minimizes the total distance.
PAM on scaled Iris, k=3, seed 42, produced silhouette 0.451 and adjusted Rand 0.676 against species, a closer species match than the K-Means centroids on the same matrix. The price is combinatorial: each medoid update inspects pairs, so this is the algorithm you use on hundreds or thousands of rows, not on hundreds of thousands.
Use it when the mean of a cluster would not be a meaningful example: a customer who is the average of everyone in the segment may not exist, while the medoid is a customer you can look up.
Settings that change this fit
- k
- How many exemplar rows are chosen. Each exemplar is a real record, so raising k adds another concrete prototype rather than another averaged point.
- metric
- Euclidean is the default. Manhattan is less sensitive to one large coordinate and is a better match for mixed-scale counts.