Abstract
Clustering is a fundamental yet computationally expensive exploratory task. Data scientists often cycle through various algorithms and cluster counts to find the most meaningful representation. This paper presents the SHiP (Similarity-Hierarchy-Partitioning) framework, which leverages the properties of ultrametrics to solve center-based clustering objectives—such as k-means, k-median, and k-center—optimally and in sorting time. By representing data as an ultrametric, the framework allows for instantaneous switching between different clustering objectives and partitioning schemes, transforming a traditionally slow iterative process into a real-time exploratory tool.
Introduction
The "guess-and-check" loop is a standard part of the clustering workflow. Because the "correct" number of clusters or the ideal objective function (e.g., minimizing squared distances vs. minimizing maximum radius) is rarely known a priori, practitioners must repeatedly run algorithms like k-means or HDBSCAN. This is inefficient, as many center-based objectives are NP-hard or require significant computational resources for each new configuration.
The authors address this by bridging hierarchical clustering, which provides a fixed structural tree, and center-based clustering, which optimizes specific distance-based objectives. They demonstrate that when data is embedded in an ultrametric space, these two paradigms converge, allowing for highly efficient optimization.
The SHiP Framework
The core of the proposed approach is the SHiP (Similarity-Hierarchy-Partitioning) framework. It operates on ultrametrics, distance functions that satisfy the strong triangle inequality: $d(x, z) \leq \max(d(x, y), d(y, z))$. These distances naturally define nested hierarchical structures known as Lowest Common Ancestor (LCA) trees.
The framework consists of three main steps:
- Similarity: Fit an initial ultrametric to the data (e.g., density-connectivity distance).
- Hierarchy: Construct a center-based hierarchy (e.g., k-means or k-median) from the ultrametric.
- Partitioning: Extract the final clusters using automated methods like elbow plots or stability thresholds.
Theoretical Foundations
The paper provides several key proofs that enable the efficiency of SHiP:
- Optimality in Ultrametrics: In Euclidean space, the farthest-first traversal algorithm is a 2-approximation for the k-center problem. The authors prove that in an ultrametric space, this same algorithm yields the optimal solution.
- Reduction to Sorting: They show that k-means and k-median objectives in an ultrametric can be reduced to a k-center problem within a "relaxed" ultrametric. Consequently, finding optimal solutions for all possible values of $k$ (from 1 to $n$) takes only $O(n \log n)$ time—equivalent to sorting the distances in the tree.
- Convexity of Cost Functions: The authors prove that the "elbow plot" (cost vs. number of clusters) is guaranteed to be convex in this setting. This mathematical guarantee makes automated cluster selection (e.g., the "Median-of-Elbows" method) significantly more reliable than in standard Euclidean clustering.
Empirical Evaluation and Results
The authors tested SHiP against a variety of synthetic and real-world datasets, including tabular data (Human Activity Recognition, MNIST) and image datasets (COIL100).
Performance and Speed
The primary advantage of SHiP is its speed. While the initial step of fitting the ultrametric may take several seconds, the subsequent steps of building the hierarchy and partitioning are nearly instantaneous.
As shown in the runtime analysis, the hierarchy construction and partitioning components of SHiP take only milliseconds. This allows researchers to explore dozens of different clustering configurations in the time it would normally take to run a single instance of a traditional algorithm.
Quality and Reliability
SHiP-derived clusterings, particularly those using density-connectivity trees, consistently match or exceed the performance of established methods like Ward’s hierarchical clustering and Spectral Clustering (SCAR) across metrics such as Adjusted Rand Index (ARI) and Normalized Mutual Information (NMI). Furthermore, the guaranteed convexity of the elbow plots ensures that the automated selection of the number of clusters is robust and reproducible.
Conclusion
The SHiP framework demonstrates that the perceived trade-off between the flexibility of center-based clustering and the efficiency of hierarchical structures is unnecessary. By leveraging the unique properties of ultrametric spaces, SHiP reduces NP-hard clustering problems to simple sorting tasks. This theoretical breakthrough provides data scientists with a powerful tool for real-time, multi-perspective data exploration without the computational burden of traditional iterative methods.
Summary updated