ArticleslgStudy

mathematics

K-medoids

K-medoids is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand K-medoids rather than just read about it. In short: The k-medoids method is used in unsupervised learning. It is a classical partitioning technique of clustering that splits a data set of n objects into k clusters, where the k number of clusters is assumed to be known a priori (which implies that the programmer must specify k before the execution of a k-medoids algorithm).

K-medoids — main illustration
K-medoids — illustration

Key takeaways

  • K-medoids belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect K-medoids to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of K-medoids from memory before moving on to harder problems.

Reference excerpt

The k-medoids method is used in unsupervised learning. It is a classical partitioning technique of clustering that splits a data set of n objects into k clusters, where the k number of clusters is assumed to be known a priori (which implies that the programmer must specify k before the execution of a k-medoids algorithm). The "goodness" of the given value of k can be assessed with methods such as the silhouette method. The name of the clustering method was coined by Leonard Kaufman and Peter J. Rousseeuw with their PAM (Partitioning Around Medoids) algorithm. The medoid of a cluster is defined as the object in the cluster whose sum (and, equivalently, the average) of dissimilarities to all the objects in the cluster is minimal. That is, it is the most centrally located point in the cluster. Unlike certain objects used by other algorithms, the medoid is an actual point in the cluster. As every point is typically assigned to its nearest medoid, the k-medoids method (like k-means clustering) does not work well if clusters vary significantly in diameter. If clusters vary in diameter or shape, other clustering methods, such as Gaussian mixture modeling or density-based clustering, may work better.

Algorithms

In general, the k-medoids problem is NP-hard to solve exactly. As such, multiple heuristics to optimize this problem exist.

Partitioning around medoids (PAM) PAM uses a greedy search method which may not find the optimum solution, but is faster than exhaustive search. It works as follows:

(BUILD) Initialize: greedily select k of the n data points as the medoids to minimize the cost Associate each data point to the closest medoid. (SWAP) While the cost of the configuration decreases: For each medoid m, and for each non-medoid data point o: Consider the swap of m and o, and compute the cost change If the cost change is the current best, remember this m and o combination Perform the best swap of m best {\displaystyle m_{\text{best}}} and o best {\displaystyle o_{\text{best}}} , if it decreases the cost function. Otherwise, the algorithm terminates. The runtime complexity of the original PAM algorithm per iteration of (3) is O ( k ( n − k ) 2 ) {\displaystyle O(k(n-k)^{2})} , by only computing the change in cost. A naive implementation recomputing the entire cost function every time will be in O ( n 2 k 2 ) {\displaystyle O(n^{2}k^{2})} . This runtime can be further reduced to O ( n 2 ) {\displaystyle O(n^{2})} , by splitting the cost change into three parts such that computations can be shared or avoided (FastPAM). The runtime can further be reduced by eagerly performing swaps (FasterPAM), at which point a random initialization becomes a viable alternative to BUILD.

Alternating optimization Algorithms other than PAM have also been suggested in the literature, including the following Voronoi iteration method known as the "Alternating" heuristic in literature, as it alternates between two optimization steps:

Select initial medoids randomly Iterate while the cost decreases: In each cluster, make the point that minimizes the sum of distances within the cluster the medoid Reassign each point to the cluster defined by the closest medoid determined in the previous step k-means-style Voronoi iteration tends to produce worse results, and exhibits "erratic behavior". Because it does not allow reassigning points to other clusters while updating means it only explores a smaller search space. It can be shown that even in simple cases this heuristic finds inferior solutions as compared to swap based methods.

Hierarchical clustering Multiple variants of hierarchical clustering with a "medoid linkage" have been proposed. The Minimum Sum linkage criterion directly uses the objective of medoids, but the Minimum Sum Increase linkage was shown to produce better results (similar to how Ward linkage uses the increase in squared error). Earlier approaches simply used the distance of the cluster medoids of the previous medoids as linkage measure, but this tends to result in worse solutions, as the distance of two medoids does not ensure there exists a good medoid for the combination. These approaches have a runtime complexity of O ( n 3 ) {\displaystyle O(n^{3})} , and when the dendrogram is cut at a particular number of clusters k, the results will typically be worse than the results found by PAM. Hence these methods are primarily of interest when a hierarchical tree structure is desired.

Other algorithms Other approximate algorithms such as CLARA and CLARANS trade quality for runtime. CLARA applies PAM on multiple subsamples, keeping the best result. By setting the sample size to O ( n ) {\displaystyle O({\sqrt {n}})} , a linear runtime (just as to k-means) can be achieved. CLARANS works on the entire data set, but only explores a subset of the possible swaps of medoids and non-medoids using sampling. BanditPAM uses the concept of multi-armed bandits to choose candidate swaps instead of uniform sampling as in CLARANS.

Visualization of the medoid-based clustering process

… excerpt ends here. Continue reading the full article.

Illustrations

K-medoids: Example of a normalized Jaccard dissimilarity graph using Nuclear Profiles. Each NP is compared to each other NP in the table, and the corresponding dissimilarity is inputted into the cell corresponding to the pair of NPs being compared. Higher numbers indicate higher dissimilarity, while lower numbers indicate higher similarity. Most labels are excluded due to size constraints. The diagonal is marked as “0” so as not to skew the data.
Example of a normalized Jaccard dissimilarity graph using Nuclear Profiles. Each NP is compared to each other NP in the table, and the corresponding dissimilarity is inputted into the cell corresponding to the pair of NPs being compared. Higher numbers indicate higher dissimilarity, while lower numbers indicate higher similarity. Most labels are excluded due to size constraints. The diagonal is marked as “0” so as not to skew the data.
K-medoids: The initial dataset that will be used throughout this section. A grey dot indicates an object that is unassigned to any cluster.
The initial dataset that will be used throughout this section. A grey dot indicates an object that is unassigned to any cluster.
K-medoids: The first center selection. The large points are centers, and the colors separate each object by its cluster.
The first center selection. The large points are centers, and the colors separate each object by its cluster.
K-medoids: The initial clusters.
The initial clusters.
K-medoids: The medoid selection.
The medoid selection.

Worked examples

Example 1 — a first encounter with K-medoids

Start with the simplest possible case. Write down what K-medoids claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to K-medoids before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about K-medoids ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of K-medoids

In research
K-medoids appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses K-medoids in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
K-medoids is common in secondary-school and first-year university syllabi. It links to neighbouring topics 1990 in artificial intelligence, Cluster analysis algorithms, Robust statistics, so understanding it makes those chapters shorter.
In everyday life
Look for K-medoids outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “K-medoids” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study K-medoids in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what K-medoids means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain K-medoids out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is K-medoids in simple terms?

The k-medoids method is used in unsupervised learning. It is a classical partitioning technique of clustering that splits a data set of n objects into k clusters, where the k number of clusters is assumed to be known a priori (which implies that the programmer must specify k before the execution of…

Why does K-medoids matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study K-medoids?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on K-medoids.

Tags

  • 1990 in artificial intelligence
  • Cluster analysis algorithms
  • Robust statistics

Keep exploring