In general, the k-medoids problem is NP-hard to solve exactly.2 As such, many heuristic solutions exist.
PAM3 uses a greedy search which may not find the optimum solution, but it is faster than exhaustive search. It works as follows:
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),4 at which point a random initialization becomes a viable alternative to BUILD.
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:567
k-means-style Voronoi iteration tends to produce worse results, and exhibit "erratic behavior".8: 957 Because it does not allow re-assigning 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 the swap based methods can solve.9
Multiple variants of hierarchical clustering with a "medoid linkage" have been proposed. The Minimum Sum linkage criterion10 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,1112 but which 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 run time 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.13 Hence these methods are primarily of interest when a hierarchical tree structure is desired.
Other approximate algorithms such as CLARA and CLARANS trade quality for runtime. CLARA applies PAM on multiple subsamples, keeping the best result. 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.14
Kaufman, Leonard; Rousseeuw, Peter J. (1990-03-08), "Partitioning Around Medoids (Program PAM)", Wiley Series in Probability and Statistics, Hoboken, NJ, USA: John Wiley & Sons, Inc., pp. 68–125, doi:10.1002/9780470316801.ch2, ISBN 978-0-470-31680-1, retrieved 2021-06-13 978-0-470-31680-1 ↩
Hsu, Wen-Lian; Nemhauser, George L. (1979). "Easy and hard bottleneck location problems". Discrete Applied Mathematics. 1 (3): 209–215. doi:10.1016/0166-218X(79)90044-1 – via Elsevier Science Direct. https://www.sciencedirect.com/science/article/pii/0166218X79900441?via%3Dihub ↩
Schubert, Erich; Rousseeuw, Peter J. (2021). "Fast and eager k -medoids clustering: O(k) runtime improvement of the PAM, CLARA, and CLARANS algorithms". Information Systems. 101: 101804. arXiv:2008.05171. doi:10.1016/j.is.2021.101804. S2CID 221103804. /wiki/Peter_Rousseeuw ↩
Maranzana, F. E. (1963). "On the location of supply points to minimize transportation costs". IBM Systems Journal. 2 (2): 129–135. doi:10.1147/sj.22.0129. /wiki/Doi_(identifier) ↩
T. Hastie, R. Tibshirani, and J. Friedman. The Elements of Statistical Learning, Springer (2001), 468–469. ↩
Park, Hae-Sang; Jun, Chi-Hyuck (2009). "A simple and fast algorithm for K-medoids clustering". Expert Systems with Applications. 36 (2): 3336–3341. doi:10.1016/j.eswa.2008.01.039. /wiki/Doi_(identifier) ↩
Teitz, Michael B.; Bart, Polly (1968-10-01). "Heuristic Methods for Estimating the Generalized Vertex Median of a Weighted Graph". Operations Research. 16 (5): 955–961. doi:10.1287/opre.16.5.955. ISSN 0030-364X. /wiki/Doi_(identifier) ↩
Schubert, Erich (2021). HACAM: Hierarchical Agglomerative Clustering Around Medoids – and its Limitations (PDF). LWDA’21: Lernen, Wissen, Daten, Analysen September 01–03, 2021, Munich, Germany. pp. 191–204 – via CEUR-WS. http://star.informatik.rwth-aachen.de/Publications/CEUR-WS/Vol-2993/paper-19.pdf ↩
Miyamoto, Sadaaki; Kaizu, Yousuke; Endo, Yasunori (2016). Hierarchical and Non-Hierarchical Medoid Clustering Using Asymmetric Similarity Measures. 2016 Joint 8th International Conference on Soft Computing and Intelligent Systems (SCIS) and 17th International Symposium on Advanced Intelligent Systems (ISIS). pp. 400–403. doi:10.1109/SCIS-ISIS.2016.0091. https://ieeexplore.ieee.org/document/7801678 ↩
Herr, Dominik; Han, Qi; Lohmann, Steffen; Ertl, Thomas (2016). Visual Clutter Reduction through Hierarchy-based Projection of High-dimensional Labeled Data (PDF). Graphics Interface. Graphics Interface. doi:10.20380/gi2016.14. Retrieved 2022-11-04. https://graphicsinterface.org/wp-content/uploads/gi2016-14.pdf ↩
Tiwari, Mo; Zhang, Martin J.; Mayclin, James; Thrun, Sebastian; Piech, Chris; Shomorony, Ilan (2020). "BanditPAM: Almost Linear Time k-Medoids Clustering via Multi-Armed Bandits". Advances in Neural Information Processing Systems. 33. https://proceedings.neurips.cc/paper/2020/hash/73b817090081cef1bca77232f4532c5d-Abstract.html ↩