Article view

Fast k-medoids Clustering in Rust and Python

By Erich Schubert, Lars Lenssen

Article information

Publication
Published 7 July 2022
Institutions at publication
TU Dortmund University
69 Citations OpenAlex, 3 December 2026 FULL LIST: Citations
Countries with citations No data yet
Usage Phase 3: not collected yet

Abstract

A popular technique to cluster non-Euclidean data using arbitrary distance functions or similarities is k-medoids. The k-medoids problem is NP-hard (Kariv & Hakimi, 1979), hence we need an approximate solution. The standard algorithm for this is Partitioning Around Medoids (PAM, Kaufman & Rousseeuw, 1987, 1990), consisting of a greedy initialization (BUILD) followed by a local optimization (SWAP). Alternatively, a k-means-style alternating optimization can be employed (Maranzana, 1963;Park & Jun, 2009), but this tends to produce worse results (Reynolds et al., 2006;Rosing et al., 1979;Teitz & Bart, 1968). FasterPAM (Schubert & Rousseeuw, 2019, 2021) recently introduced a speedup for larger k, by exploiting redundancies when computing swaps for all k existing medoids. Originally FasterPAM was implemented in Java and published within the open-source library ELKI (Schubert & Zimek, 2019). Here, we introduce the kmedoids Rust crate (https://github.com/kno10/rust-kmedoids)along with a Python wrapper package kmedoids (https://github.com/kno10/python-kmedoids) to make this fast algorithm easier to employ by researchers in various fields. We implemented the FasterPAM approach, the original PAM, and the "Alternating" (k-means-style) approach. The implementation can be used with arbitrary dissimilarities and distances, as it requires a dissimilarity matrix as input.

Citations per year

Citations per year
YearCitations
2022 1
2023 8
2024 17
2025 17
2026 26

OpenAlex counts citations by year for the last ten years only, so the total and the list of citing works can include earlier ones.

Works citing this article

OpenAlex counts 69 citations, but the citing work are not listed here yet: citing works are collected from OpenAlex a few at a time, and it lists most, not all, of the citations it counts.

Where its authors are based

Countries of the institutions the article's authors were affiliated to when it was published.

  • AUTHORS
  • CITATIONS No data yet
  • USAGE Phase 3
Authors by country
CountryAuthors
Germany2