Reproducible clustering with non-Euclidean distances: a simulation and case study

Lauren L. Staples, Janelle Ring, Scott Fontana, Christina Stradwick, Joe DeMaio, Herman E. Ray, Yifan Zhang, Xinyan ZhangInternational Journal of Data Science and Analytics 2023

Abstract

Certain categorical sequence clustering applications require path connectivity, such as the clustering of DNA, click-paths through web-user sessions, or paths of care clustering with sequences of patient medical billing codes. $K$-means and $k$-medoids clustering with non-Euclidean distance metrics such as the Jaccard or edit distances maintains such path connectivity. Although $k$-means and $k$-medoids clustering with the Jaccard and edit distances have enjoyed success in these domains, the limits of accurate cluster recovery in these conditions have not yet been defined. As a first step in approaching this goal, we performed a simulated study using $k$-means and $k$-medoids clustering with non-Euclidean distances and show the performance deteriorates at a certain level of noise and when the number of clusters increases. However, we identify initialization strategies that improve upon cluster recovery in the presence of noise. We employ the use of the Tibshirani and Guenther Prediction Strength method, which creates a hypothesis testing scenario that determines if there is clustering structure to the data (if the clusters are reproducible), with the null hypothesis being there is none. We then applied the framework to perinatal episodes of care and the clusters reproducibly and organically split between Cesarean and vaginal deliveries, which itself is not a clinical finding but sensibly validates the approach. Further visualizations of the clusters did bring insights into subclusters that split along groups of physicians, cost and risk scores, warranting the outlined future work into ways of improving this framework for better resolution.

Introduction

Clustering is a cornerstone of unsupervised machine learning, yet its application to categorical sequences—such as DNA, web click-paths, or patient journeys through a healthcare system—presents significant challenges. In these contexts, standard Euclidean distance metrics are often inapplicable. Instead, researchers utilize non-Euclidean metrics like the Jaccard distance (measuring set overlap) or Edit distance (measuring the cost of sequence transformations).

A critical requirement in these domains is "path connectivity." For example, when clustering medical billing codes, the cluster center (medoid) must represent a valid, observable sequence of events rather than a mathematical average of coordinates that may never have occurred. Furthermore, unsupervised algorithms are prone to identifying patterns even within random noise. This study addresses the lack of defined theoretical limits for cluster recovery in non-Euclidean spaces and proposes a rigorous framework to ensure discovered clusters are reproducible and statistically significant.

Methodology

The research focuses on $k$-medoids clustering because, unlike $k$-means, the cluster center is always an actual observed data point, thereby ensuring path connectivity.

Initialization Strategies

The authors evaluated several initialization strategies to improve accuracy in noisy data. These included the standard $k$-medoids++ and an extended version termed Sum Distance $k$-medoids++ (SDK), alongside versions with restricted randomness. The goal was to determine if smarter starting points could mitigate the impact of noise on cluster recovery.

Validation via Prediction Strength (PS)

To validate cluster quality, the study employed Tibshirani and Guenther’s Prediction Strength (PS) metric. Unlike the commonly used Silhouette width, PS utilizes a cross-validation approach: it clusters a training set and then evaluates whether those cluster boundaries remain stable when applied to a test set. Crucially, PS allows for a "null hypothesis" ($k=1$), providing a statistical safeguard that can identify when no meaningful clustering structure exists in the data.

Experimental Setup

Simulated Datasets

The framework was first tested on 27 distinct simulated datasets. These datasets featured "true" cluster counts ($k$) ranging from 2 to 10 and included varying levels of noise (randomly injected characters) and sequence shuffling to mimic the variability found in real-world data.

Real-World Case Study: Perinatal Episodes of Care

The framework was then applied to a massive dataset of 22,773 perinatal episodes of care from a 2016 Medicaid cohort. This dataset comprised medical billing codes (CPT, ICD-10) representing the clinical path of each patient from pregnancy through delivery.

Results and Discussion

Simulation Performance

Results from the simulations indicated that cluster recovery accuracy deteriorates as the number of true clusters increases and as noise levels rise. However, the SDK initialization strategy significantly improved the odds of recovering the true number of clusters, outperforming standard $k$-medoids++ by approximately 20-50% depending on the distance metric used.

Case Study Validation

In the perinatal case study, the Jaccard distance (focusing on the presence of codes) proved more effective than the Edit distance (focusing on the order of codes). Using Jaccard distance with PS, the model consistently identified two reproducible clusters across different geographic regions. These clusters organically separated into Cesarean and vaginal deliveries with high purity (92.5% to 98%), validating that the algorithm was capturing fundamental clinical differences.

The "Null" Result and Sub-cluster Insights

When applying the Edit distance to the case study, the PS metric returned a "Null" result for all regions. This highlights the framework's ability to prevent researchers from over-interpreting noisy sequence data where the chronological order may be too stochastic to form reproducible patterns.

Despite the primary clinical split, 3D projections of the Jaccard distance matrix revealed deeper sub-clusters tied to specific physician groups, healthcare costs, and patient risk scores. This suggests that while the primary signal is clinical, the framework can uncover nuanced operational and economic patterns.

Conclusion and Future Work

This study provides a robust framework for reproducible clustering in non-Euclidean spaces. By combining $k$-medoids with SDK initialization and Prediction Strength validation, researchers can more reliably distinguish true signal from noise in complex categorical sequences.

Future research directions include implementing TF-IDF style weighting to emphasize rare, highly-informative medical codes, incorporating actual timestamps via Dynamic Time Warping, and further refining medoid selection to improve resolution in high-noise environments.

Summary updated

BibTeX
@article{staples2023reproducible,
  author = {Lauren L. Staples and Janelle Ring and Scott Fontana and Christina Stradwick and Joe DeMaio and Herman E. Ray and Yifan Zhang and Xinyan Zhang},
  title = {{Reproducible clustering with non-Euclidean distances: a simulation and case study}},
  journal = {International Journal of Data Science and Analytics},
  year = {2023},
  doi = {10.1007/s41060-023-00429-1},
}
Figure