Bootstrapping Your Own Positive Sample: Contrastive Learning With Electronic Health Record Data

Tingyi Wanyan, Jing Zhang, Ying Ding, Ariful Azad, Zhangyang Wang, Benjamin S. GlicksbergarXiv 2021

Introduction

Predicting clinical outcomes from Electronic Health Record (EHR) data is a cornerstone of modern medical informatics, yet it remains fraught with challenges. Two primary hurdles often impede model performance: severe class imbalance and high intra-class variance. In many clinical settings, the event of interest—such as mortality or a rare disease diagnosis—occurs in only a small fraction of the population. Furthermore, patients who share the same outcome may present with vastly different clinical phenotypes. For example, two patients at high risk of COVID-19 mortality might exhibit entirely different physiological signatures, with one showing respiratory distress and another systemic inflammation.

This paper introduces a specialized contrastive learning framework designed to address these issues by effectively "bootstrapping" positive samples from within the dataset, allowing models to learn more robust and representative patient embeddings.

The Challenge of Contrastive Learning in Medicine

Contrastive Learning (CL) has seen massive success in computer vision, where models learn by pulling together different versions of the same image (e.g., a rotated or cropped photo) and pushing apart different images. However, these "data augmentation" techniques do not translate to the medical domain. One cannot simply "rotate" or "crop" a patient's longitudinal lab results without destroying the underlying medical reality.

To bridge this gap, the authors propose a Contrastive-Regularized Focal Loss framework. Instead of creating synthetic versions of a single patient, the model identifies other similar patients to serve as "positive samples."

Methodology: Proximity-Based Sampling

The core innovation of this work lies in its two novel strategies for selecting positive samples to regularize the learning process:

  1. Feature-based Positive Sampling: This dynamic approach builds a k-nearest neighbor (kNN) graph within the model's embedding space. During each training epoch, the model identifies the most similar patients within the same class based on their current learned representations and pulls them closer together.
  2. Attribute-based Positive Sampling: This static approach uses raw clinical data—specifically 34 key lab tests—to calculate patient similarity via Euclidean distance before training begins. By anchoring the model to pre-computed clinical similarities, it ensures that patients with similar physiological profiles are grouped together.

By using these proximity-based strategies rather than random sampling, the framework prevents "feature collapse," where the model might otherwise try to force highly heterogeneous patients into a single, poorly defined cluster.

Experimental Results

The framework was evaluated using a real-world dataset of 5,712 COVID-19 patients from a large urban health system. The task was to predict mortality 24 hours before the event occurred.

Performance and Robustness

The proposed method established a new state-of-the-art for this dataset:

  • Top Performance: The Focal Loss combined with Attribute-based sampling achieved an AUROC of 0.959 and an AUPRC of 0.886.
  • Baseline Comparison: This significantly outperformed standard Cross-Entropy (0.873 AUROC) and the strong Focal Loss baseline (0.931 AUROC).

Perhaps most impressively, the framework demonstrated remarkable robustness to data scarcity. In experiments where the training data was restricted to a 1% mortality rate, the contrastive regularizer provided a 9% performance improvement over vanilla focal loss, which struggled to maintain accuracy under such extreme imbalance.

Discussion and Future Work

The success of the attribute-based approach suggests that raw clinical similarity is a powerful anchor for deep learning models. However, the authors note that this reliance on pre-selected features (the 34 lab tests) requires domain expertise and may vary depending on the disease being studied.

Future research directions include exploring the generalizability of these patient embeddings across multiple tasks—such as predicting length-of-stay or readmission—and optimizing the computational efficiency of building kNN graphs for million-patient datasets. By treating similar patients as "natural augmentations," this framework provides a scalable path forward for applying contrastive learning to the complexities of human health data.

Summary updated

BibTeX
@misc{wanyan2021bootstrapping,
  author = {Tingyi Wanyan and Jing Zhang and Ying Ding and Ariful Azad and Zhangyang Wang and Benjamin S. Glicksberg},
  title = {{Bootstrapping Your Own Positive Sample: Contrastive Learning With Electronic Health Record Data}},
  year = {2021},
  eprint = {2104.02932},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2104.02932},
}
Figure