Skip to main content
QUICK REVIEW

[Paper Review] Contrastive Learning of Temporal Distinctiveness for Survival Analysis in Electronic Health Records

Mohsen Nayebi Kerdabadi, Arya Hadizadeh Moghaddam|arXiv (Cornell University)|Aug 24, 2023
Machine Learning in HealthcareComputer Science3 citations
TL;DR

This paper proposes OTCSurv, a novel contrastive learning framework for survival analysis in electronic health records that leverages temporal distinctiveness—measured by survival duration differences— to construct hardness-aware negative pairs. By integrating an ontology-aware sequential encoder with a supervised weighted contrastive loss, OTCSurv improves both risk ranking and time-to-event prediction, achieving state-of-the-art performance on AKI prediction with enhanced model interpretability through attention analysis.

ABSTRACT

Survival analysis plays a crucial role in many healthcare decisions, where the risk prediction for the events of interest can support an informative outlook for a patient's medical journey. Given the existence of data censoring, an effective way of survival analysis is to enforce the pairwise temporal concordance between censored and observed data, aiming to utilize the time interval before censoring as partially observed time-to-event labels for supervised learning. Although existing studies mostly employed ranking methods to pursue an ordering objective, contrastive methods which learn a discriminative embedding by having data contrast against each other, have not been explored thoroughly for survival analysis. Therefore, in this paper, we propose a novel Ontology-aware Temporality-based Contrastive Survival (OTCSurv) analysis framework that utilizes survival durations from both censored and observed data to define temporal distinctiveness and construct negative sample pairs with adjustable hardness for contrastive learning. Specifically, we first use an ontological encoder and a sequential self-attention encoder to represent the longitudinal EHR data with rich contexts. Second, we design a temporal contrastive loss to capture varying survival durations in a supervised setting through a hardness-aware negative sampling mechanism. Last, we incorporate the contrastive task into the time-to-event predictive task with multiple loss components. We conduct extensive experiments using a large EHR dataset to forecast the risk of hospitalized patients who are in danger of developing acute kidney injury (AKI), a critical and urgent medical condition. The effectiveness and explainability of the proposed model are validated through comprehensive quantitative and qualitative studies.

Motivation & Objective

  • To address the limitations of existing survival models in handling censored data and learning discriminative patient representations from longitudinal EHRs.
  • To explore contrastive learning in survival analysis, particularly using temporal duration differences as a basis for negative sampling hardness.
  • To improve both risk ordering and precise time-to-event prediction in survival modeling using a multi-task learning approach.
  • To enhance model interpretability by leveraging attention mechanisms to highlight critical visits and medical codes in patient histories.
  • To incorporate medical ontology knowledge into representation learning for better generalization, especially for rare or sparse medical codes.

Proposed method

  • The model uses a dual-encoder architecture: an ontological encoder to map ICD-9 codes to hierarchical medical concepts and a sequential self-attention encoder to model temporal dependencies in patient visits.
  • A supervised weighted contrastive loss (SupWCon) is designed to contrast patient embeddings based on survival duration differences, with temperature parameters adjusted by the time gap between pairs to reflect sampling hardness.
  • Negative pairs are constructed using survival durations from both censored and observed patients, ensuring that time-to-event differences inform contrastive learning.
  • The framework jointly optimizes three objectives: SupWCon for contrastive representation learning, a ranking loss for concordance, and a regression loss for time prediction.
  • Instance-level and visit-level attention-pooling mechanisms are used to generate interpretable attention weights for visits and individual medical codes.
  • The ontological encoder uses hierarchical relationships in medical ontologies (e.g., ICD-9) to improve embeddings for rare or low-frequency codes by attending to broader parent concepts.
Figure 1. Architecture of the proposed OTCSurv model. There are three main components: 1) Sequential attention-based ontological encoder, which mainly consists of an ontological encoder, two attention-pooling blocks, and a transformer encoder to learn the ultimate instance-level representations of p
Figure 1. Architecture of the proposed OTCSurv model. There are three main components: 1) Sequential attention-based ontological encoder, which mainly consists of an ontological encoder, two attention-pooling blocks, and a transformer encoder to learn the ultimate instance-level representations of p

Experimental results

Research questions

  • RQ1Can contrastive learning based on temporal distinctiveness—measured by survival duration differences—improve representation learning in survival analysis of EHRs?
  • RQ2How does incorporating survival duration differences into negative sampling hardness enhance model performance compared to uniform or random negative sampling?
  • RQ3To what extent does integrating medical ontology knowledge improve representation quality, especially for rare or sparse medical codes in EHRs?
  • RQ4Can a multi-task learning framework combining contrastive, ranking, and regression losses simultaneously improve risk ordering and time prediction accuracy?
  • RQ5How do attention weights in the model reflect clinically meaningful patterns, such as critical visits or high-impact diagnoses, in patient-level decision-making?

Key findings

  • OTCSurv achieves state-of-the-art performance on AKI prediction in a large real-world EHR dataset, outperforming existing methods in both concordance index (c-index) and time prediction accuracy.
  • The proposed SupWCon loss significantly improves model performance by dynamically adjusting contrastive temperature based on survival duration differences, enhancing learning from hard negative pairs.
  • Attention analysis reveals that visit 5, with high attention weight, and codes such as 572 (liver disease), 410 (myocardial infarction), and 287 (hemorrhagic conditions), are most predictive of AKI onset, aligning with clinical literature.
  • The ontological encoder effectively improves representations for rare codes by attending to broader, more frequent parent concepts—e.g., ICD-9 code 514 receives attention via its ancestor 460-519.
  • Ablation studies confirm that removing the contrastive loss or the ontology component leads to significant performance drops, validating their contributions.
  • The model demonstrates strong interpretability, with attention weights clearly identifying clinically relevant visits and diagnoses, supporting clinical trust and transparency.
Figure 2. Comparison of the mean survival curves of proposed model and baselines with Kaplan-Meier curve (for all patients).
Figure 2. Comparison of the mean survival curves of proposed model and baselines with Kaplan-Meier curve (for all patients).

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.