Fast and Memory-Light Evaluation of Density-Based Clusterings with the DISCO Index in R

Amin EntezariarXiv 2026

Evaluating the quality of a clustering result is notoriously difficult when you don't have ground-truth labels. While classical metrics like the Silhouette coefficient are staples in the data scientist's toolkit, they often fail miserably when applied to density-based algorithms like DBSCAN or HDBSCAN. These algorithms are designed to find clusters of arbitrary shapes and—crucially—to identify "noise" points that don't belong anywhere.

A new paper by Amin Entezari introduces a significant upgrade to the DISCO index, a modern validity index tailored for these complex scenarios. By rethinking the underlying mathematics, the author has transformed DISCO from a memory-hungry calculation into a lean, lightning-fast tool available in the R package discoCVI.

TL;DR

The discoCVI package provides a high-performance implementation of the DISCO index for R, enabling the evaluation of density-based clusterings on large datasets. By replacing $O(n^2)$ memory-intensive distance matrices with a linear-memory tree traversal, the new version is up to 138x faster and can score 100,000 points in under a minute on a standard laptop.

What Problem Does This Paper Address?

Internal Cluster Validity Indices (CVIs) are essential for hyperparameter tuning (e.g., choosing minPts in DBSCAN) when you have no labels to check against. However, traditional CVIs assume clusters are convex (blob-like) and have no concept of "noise."

The DISCO index, recently proposed by Beer et al. (2026), solves this by specifically evaluating how well noise points are handled—penalizing noise that is actually in a dense region and rewarding noise that is truly isolated. The catch? The original definition required calculating and storing "density-connectivity distances" between every single pair of points. For a dataset of just 10,000 points, this requires a matrix with 100 million entries, quickly exhausting the RAM of most workstations.

Methods

The core contribution of this paper is a "key observation" that bypasses the need for massive matrices. The author proves that the density-connectivity distance between any two points is exactly equal to the height at which they are merged in a single-linkage merge tree (derived from a mutual-reachability minimum spanning tree).

Instead of building an $n \times n$ matrix, the discoCVI package (version 0.2.0) now:

  1. Computes core distances using fast nearest-neighbor searches (FNN).
  2. Builds a Minimum Spanning Tree (MST) using Prim’s algorithm.
  3. Constructs a merge tree.
  4. Performs a single bottom-up and top-down pass over the tree to accumulate the sums and minima required for the DISCO score.

This shifts the memory requirement from quadratic ($O(n^2)$) to linear ($O(n)$), making the index practical for "big data" applications.

Datasets

The author evaluated the implementation using:

  • Synthetic "Half-Moons": A classic benchmark for density-based clustering consisting of two interleaving crescents and uniform noise.
  • Scaling Benchmarks: Synthetic datasets featuring three Gaussian clusters in 2D with 5% noise, scaled from 500 up to 100,000 points to measure time, memory, and energy consumption.

Key Insights and Ideas

  • The "Aha" Moment: Realizing that all the global information needed for DISCO is encoded in the topology of the MST merge tree. This allows a global metric to be computed through local tree recursions.
  • Noise as a First-Class Citizen: Unlike other indices that simply ignore points labeled as -1, DISCO provides a "pointwise" score. As seen in Figure 1, this allows researchers to visually inspect which specific points are "borderline" or poorly classified.
Figure 1: Pointwise DISCO scores of the HDBSCAN clustering. Colours run from red (score −1) through yellow (0) to blue (+1), so light-blue points are well placed and yellowish points are borderline; crosses mark points labelled as noise.
  • Energy Efficiency: Because the new algorithm avoids massive memory swaps and finishes much faster, it is significantly "greener." Scoring 4,000 points with the new version uses about the same energy as scoring just a few hundred points with the old version.

Key Results

The performance gains are dramatic. In head-to-head tests against the previous R version and the reference Python implementation:

  • Speedup: Version 0.2.0 is 138 times faster than version 0.1.1 at 4,000 points.
  • Memory Efficiency: While the old version crashed at 8,000 points due to memory limits, the new version handles 100,000 points using less than 200 MB of RAM.
Figure 3: Peak memory (maximum resident set size) of the whole R process; the dashed line marks the memory used by R itself. Points are medians and bars the range over five runs.
Figure 2: Time to compute the DISCO score as a function of the number of points (log-log scale). Points are medians and bars the range over five runs.

Limitations and Future Work

While memory is now linear, the running time is still technically quadratic ($O(n^2)$) because of the initial Minimum Spanning Tree construction. The author notes that for very low-dimensional data, this could be improved to $O(n \log n)$ using dual-tree Borůvka algorithms.

Additionally, the current package is optimized for Euclidean distances. Future versions may expand to support arbitrary dissimilarity measures and potentially reuse the MSTs already calculated by algorithms like HDBSCAN to further reduce redundant computation.

Summary updated

Abstract

DISCO is a recent internal cluster validity index for density-based clustering that, unlike earlier indices, also evaluates the quality of noise labels. The discoCVI package makes DISCO available in R. This article describes the design of the package and a typical workflow, in which DISCO is used to compare clusterings and to choose the parameters of HDBSCAN without ground truth, followed by the implementation introduced in version 0.2.0. DISCO is defined through density-connectivity distances between all pairs of points, so direct implementations store several n-by-n matrices. We show that every quantity DISCO needs can be read off the single-linkage merge tree of the mutual-reachability minimum spanning tree, so that the index can be computed exactly with memory that grows linearly with the number of points, while the running time remains quadratic as in the original definition. The implementation is tested against the previous version, agrees with the original Python implementation to within $3 \times 10^{-13}$, and corrects the score of singleton clusters to match the published definition. In benchmarks, discoCVI is 23 to 138 times faster than its previous version for 500 to 4,000 points and 3 to 9 times faster than the Python reference for 500 to 8,000 points, using a fraction of the memory of both, and it scores 100,000 points in about 50 seconds with less than 200 MB of memory.
BibTeX
@misc{entezari2026fast,
  author = {Amin Entezari},
  title = {{Fast and Memory-Light Evaluation of Density-Based Clusterings with the DISCO Index in R}},
  year = {2026},
  eprint = {2611.25114},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.25114},
}
Figure