Dynamic Similarity Graph Construction with Kernel Density Estimation

Steinar Laenen, Peter Macgregor, He Sun

TL;DR

This paper introduces the first efficient dynamic algorithms for Kernel Density Estimation (KDE) and similarity graph construction. By leveraging locality-sensitive hashing and a novel hierarchical data structure, the authors achieve $(1 \pm \epsilon)$-approximate updates in sub-linear time, enabling fast spectral clustering on datasets that grow over time.

Problem Statement

Kernel Density Estimation (KDE) is a cornerstone of non-parametric statistics and machine learning, used to estimate the probability density function of a dataset. Similarly, similarity graphs—where edges represent the "closeness" of data points—are essential for graph-based clustering methods like spectral clustering.

The major bottleneck is that these operations are traditionally static. In a static setting, constructing a similarity graph for $n$ points takes $O(n^2)$ time. If a dataset is dynamic (e.g., a streaming service adding new users), adding even a single point typically requires recomputing the entire structure to maintain accuracy. While some dynamic KDE estimators existed, none could efficiently maintain query estimates under a continuous stream of data insertions while providing strong theoretical guarantees on accuracy.

Proposed Methods

The authors propose two primary dynamic data structures:

  1. Dynamic KDE: Built upon the "CKNS" framework, this algorithm uses Locality Sensitive Hashing (LSH) and importance sampling. The key innovation is a "query-hash" structure. When a new data point $z$ is added, the algorithm doesn't just update the data buckets; it uses the hash to quickly identify exactly which query points $q$ would have their density estimates significantly altered by $z$ and updates them specifically. This results in an amortized update time of roughly $n^{0.25}$ for Gaussian kernels.
LSH-based dynamic KDE update mechanism using data and query hashing to identify affected points.
  1. Dynamic Similarity Graph: To build a graph that evolves with the data, the authors use a hierarchical tree where each internal node maintains a dynamic KDE estimator. This tree allows the algorithm to adaptively resample edges. If a new point $z$ changes the density estimate of an existing point $x$ beyond a certain threshold, the algorithm "resamples" the neighbors of $x$. This ensures the graph remains sparse (only $O(n \log n)$ edges) while theoretically preserving the cluster structure of the underlying data.

Datasets

The algorithms were evaluated on a diverse mix of 8 datasets, ranging from 20,000 to over 2.4 million points:

  • Real-world: aloi (images), msd (Million Song Dataset), covtype (forest cover), glove (word embeddings), census (1990 US Census), mnist (handwritten digits), cifar10 (image embeddings), and shuttle (NASA logs).
  • Synthetic: blobs (isotropic Gaussian blobs for clustering testing).

Key Insights

  • Decoupling Updates: The update time for data insertions is independent of the number of query points $|Q|$. LSH buckets act as a filter, ensuring the system only touches queries affected by the new data point.
  • Cluster Preservation: The authors provide a theoretical guarantee that their sparse dynamic graph is a cluster-preserving sparsifier. The conductance and eigenvalue gaps of the dynamic graph closely match those of the fully connected $O(n^2)$ graph.
  • Adaptive Resampling: The tree structure allows for "local" surgery. Only the branches of the tree affected by the new point's density are updated, which is why the update time remains sub-linear.

Key Results

  • Sub-linear Scaling: On the census dataset (2.4M points), the dynamic KDE algorithm's update time was shown to be sub-linear, whereas baseline algorithms (like EXACT or re-computing CKNS) scaled linearly or quadratically.
Update time comparison showing the sub-linear scaling of the proposed algorithm vs. EXACT and CKNS baselines.
  • Speedup: For the Gaussian kernel, the update time is approximately $n^{0.25}$. In practice, on large datasets like msd, the proposed algorithm was orders of magnitude faster than re-running a static KDE algorithm at every step.
  • Clustering Performance: In spectral clustering tests, the dynamic similarity graph achieved Normalized Mutual Information (NMI) scores comparable to the "gold standard" fully-connected graph. For example, on the blobs dataset, it achieved a perfect NMI of 1.0 while being significantly faster than $k$-Nearest Neighbor (kNN) baselines.

Limitations and Future Work

  • Insertion Bias: While the KDE portion discusses deletions, the similarity graph construction is primarily optimized for insertions. Handling frequent deletions while maintaining cluster-preservation guarantees remains a challenge.
  • Kernel Dependency: Efficiency depends on the kernel function used. While it works for Gaussian, Exponential, and Student-t kernels, extremely complex or non-smooth kernels might see diminished returns.
  • Memory Overhead: Maintaining the hierarchical tree and multiple LSH hash tables requires more memory than a simple static array, which might be a constraint for memory-limited edge devices.

Summary updated

BibTeX
@inproceedings{laenen2025dynamic,
  author = {Steinar Laenen and Peter Macgregor and He Sun},
  title = {{Dynamic Similarity Graph Construction with Kernel Density Estimation}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=stgw28KnaX},
}
Figure