A Parameter-free Affinity Based Clustering

Bhaskar Mukhoty, Ruchir Gupta, Y. N. Singh

TL;DR

This paper introduces a novel, parameter-free clustering algorithm that mimics human visual cognition to automatically detect natural groups and determine the optimal number of clusters in a dataset. By transforming Euclidean distances into affinity scores and analyzing their distribution via a simple histogram, the method effectively isolates outliers and merges close-lying groups without requiring any user-defined parameters like $k$ or neighborhood radii.

What Problem Does This Paper Address?

Clustering is a fundamental unsupervised learning task, but most traditional algorithms suffer from a common flaw: they require human guidance. Partitioning methods like $K$-means require you to specify the exact number of clusters ($k$) beforehand. Density-based methods like DBSCAN don't need $k$, but they require sensitive hyperparameters like neighborhood radius ($\epsilon$) and minimum point thresholds.

To automatically find $k$, researchers typically use Cluster Validity Indexes (CVIs) to evaluate a range of cluster numbers iteratively—a computationally expensive "guess-and-check" strategy. The authors of this paper challenge this status quo, proposing an algorithm that discovers the natural structure of data in a single, deterministic run without any prior parameters, imitating how humans instantly recognize clusters through visual proximity.

Methods

The proposed algorithm operates in two primary phases: Finding Initial Clusters and Merging Clusters.

  1. Affinity Mapping: After standardizing the data using z-scores, the algorithm computes an all-pairs Euclidean distance matrix. It transforms these distances into affinity scores (ranging from 0 to 1) using a modified Gaussian function: $$A(i, j) = \exp\left(\frac{-D(i, j)^2}{2\sigma_D'^2}\right)$$ where $\sigma_D'$ is a flattened standard deviation designed to handle both intra- and inter-cluster distances smoothly.

  2. Dynamic Thresholding: The algorithm plots a 10-bin histogram of these affinity scores. It identifies the threshold where the maximum positive change in affinity count occurs, separating strong intra-cluster connections from weak inter-cluster ones.

  3. Sequential Search (findClusters): Starting with an unclustered point, the algorithm groups all points with affinities above the threshold, dynamically updating the cluster's centroid. Single-point clusters at the end of this phase are automatically flagged as outliers.
  4. Intelligent Merging (mergeClusters): To handle datasets where clusters are close or overlapping, the authors introduce a modified cost function $W(C)$ that decreases when close clusters are merged (unlike traditional Sum of Squares Within, which always increases as cluster counts drop). The final number of clusters is estimated by analyzing the skewness and distribution of the initial cluster sizes.
An affinity histogram showing a sharp rise in high-affinity pairs, helping determine the threshold.

Datasets

The algorithm was evaluated on 27 distinct datasets spanning real-world and synthetic benchmarks:

  • Real-World Datasets: Iris, Thyroid, Car, Breast Cancer, and WDBC (Wisconsin Diagnostic Breast Cancer) from the UCI repository.
  • Synthetic Datasets: Standard convex clustering benchmarks (S1–S4, D31, R15, Uniform, Diagonal, and Dim2–Dim1024).
  • Noisy/Density-Varying Datasets: Five challenging datasets (d8c8N, d8c4N, etc.) containing high-dimensional data with 10% added noise/outliers specifically designed to test cluster validity indexes.

Key Insights and Ideas

  • The "Aha" Moment on Cost Functions: Traditional Sum of Squares Within (SSW) is useless for evaluating merges because it mathematically must increase when you reduce the number of clusters. By weighting the inverse of cluster size ($1/s_j$) in their new cost function $W(C)$, the authors created a metric that actually decreases when a merge is genuinely favorable.
  • Prioritizing the Big Picture: In datasets that support merging, the distribution of initial cluster sizes is highly skewed (lots of tiny clusters, few large ones). The algorithm mathematically prioritizes large clusters as the true representatives of the data structure, using a weighted inequality to find the cutoff point $k$.
The distribution of initial cluster sizes for the thyroid dataset, demonstrating how the algorithm identifies the true number of major clusters.

Key Results

  • Superior Accuracy in Estimating $k$: The proposed algorithm correctly predicted the exact number of clusters in 21 out of 27 datasets (77.7% accuracy). In comparison, top-performing traditional indexes like Silhouette and Davies-Bouldin only achieved 26.9% accuracy.
A comparison graph highlighting the proposed method's dramatic improvement in cluster number estimation accuracy over traditional indexes.
  • Robust Noise Handling: On heavily noised datasets (like d8c8N), the algorithm successfully isolated 10% of the data points as outliers while perfectly clustering the remaining data, outperforming standard partitioning and hierarchical methods.
Visual representation of the algorithm successfully identifying distinct clusters and isolating scattered background noise/outliers.
  • High Cluster Quality: When evaluated using external metrics (Adjusted Rand Index, Jaccard Index, and F1 measure), the algorithm outperformed or matched established methods like $K$-means++, Ward’s linkage, and Gaussian Mixture Models (GMM), particularly on noisy datasets.

Limitations and Future Work

While powerful, the algorithm has two notable limitations:

  1. Computational Complexity: Computing the all-pairs distance and affinity matrices requires $O(n^2)$ time and space complexity. This makes it less suitable for massive, web-scale datasets without further optimization.
  2. Convex Geometry Assumption: Because the merging phase relies on centroid distances, the algorithm is optimized for convex (spherical or hyper-spherical) cluster shapes. It will struggle with complex, non-convex geometries (like concentric rings or interlocking spirals) that density-based methods like DBSCAN can naturally navigate.

The authors note that future work will focus on reducing the algorithm's computational complexity and adapting the affinity framework to handle non-convex, arbitrary shapes.

Summary updated

BibTeX
@misc{mukhoty2015parameter,
  author = {Bhaskar Mukhoty and Ruchir Gupta and Y. N. Singh},
  title = {{A Parameter-free Affinity Based Clustering}},
  year = {2015},
  eprint = {1507.05409},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1507.05409},
}
Figure