Predicting Lab Abnormalities from Full EHR Event Sequences with a Causal Temporal Transformer

Julian Ezra Samuel, Ryan King, Sadeer Al-Kindi, Bobak J MortazaviBHI 2026

TL;DR

Most clinical AI models throw away the majority of a patient’s medical history—squashing it into summary statistics or chopping it off after a few hours—before making a prediction. This paper shows that keeping the full, messy timeline of an ICU stay (up to 2,048 events) lets a surprisingly tiny, 2-million-parameter transformer predict whether an upcoming lab test will be low, normal, or high with state-of-the-art accuracy. Even better, the model spontaneously learns real human physiology along the way.

What Problem Does This Paper Address?

In the ICU, a patient’s chart is afirehose of irregular, heterogeneous events: lab draws, vital signs, medications, and procedures, all happening at odd intervals. Anticipating abnormal lab results before the bloodwork comes back can give clinicians a crucial head start on physiological deterioration.

However, existing models struggle with this. Traditional machine learning approaches (like XGBoost) rely on handcrafted summary statistics—means, mins, and maxes—that erase the exact timing and sequence of events. Meanwhile, newer "foundation models" for Electronic Health Records (EHRs) either ignore numeric values altogether or convert every event into text tokens. Because a single clinical event expands into roughly 13 text tokens, a 4,096-token LLM context window can only fit about 310 events. For complex ICU patients whose stays accumulate thousands of events, the model is forced to fly blind on everything that happened earlier.

Methods

The authors introduce the Causal Temporal Classifier (CTC), a lightweight, 2-layer causal transformer (~2M parameters) built specifically for long, irregular clinical timelines.

Fig. 1. Architecture of the Causal Temporal Classifier (CTC). Each EHR event is encoded as a triplet of code, value, and time embeddings and processed through a causal transformer with Time-Aware RoPE. The model attends causally over the full patient timeline — including demographics, lab events, and medications — and predicts the class (low/normal/high) of a masked query lab value at its position in the sequence. Here, the model predicts Hemoglobin as High (88%) given the preceding context.

Instead of converting events into text, CTC represents each clinical event as a compact triplet: (code_id, z-scored value, log(1+t)), where t is minutes since admission. Each component is projected and summed into a single token embedding. To predict an upcoming lab, the model appends a masked query token at the end of the sequence and predicts whether the result will be low, normal, or high based on sex-stratified clinical reference ranges.

Two design choices stand out:

  1. Efficiency at scale: One event equals one token. This lets CTC process up to 2,048 events without breaking a sweat—nearly 7× the history of text-based models like LabTOP.
  2. Time-Aware RoPE: Standard transformers use Rotary Position Embeddings (RoPE) based on integer token indices (event 1, event 2, etc.). CTC adapts RoPE to use continuous, log-transformed clinical timestamps, giving the attention mechanism direct awareness of how much real time elapsed between any two events.

Datasets

The authors evaluate their approach on two large, publicly available North American ICU datasets:

  • MIMIC-IV: 93,211 ICU stays from Beth Israel Deaconess Medical Center (6.1M training examples, 1.6M test examples).
  • eICU-CRD: 183,795 ICU stays across hundreds of U.S. hospitals (14M training examples, 1.7M test examples).

They use a patient-level 80/10/10 train/validation/test split and evaluate 44 analytes on MIMIC-IV and 40 on eICU.

Key Insights and Ideas

  • More history consistently helps: Doubling the context window from 310 to 610 events—and again to 2,048 events—yields steady, measurable gains in both AUC and Macro F1. While most of the signal lives in the recent few hundred events, long-range dependencies still matter for complex, long-stay patients.
  • Compact beats massive: Despite having only ~2M parameters, CTC outperforms much larger EHR foundation models like GenHPF (~11M parameters) and LabTOP (~55M parameters), as well as per-analyte XGBoost models.
  • Emergent physiology: Without ever being explicitly taught medical rules, CTC learns clinically valid relationships. When the authors counterfactually perturbed a patient's context labs—for example, pushing Hemoglobin and RBCs artificially high—the model shifted its Hematocrit prediction from low to high, mirroring the real-world physiological rule ($\text{Hct} \approx 3 \times \text{Hgb}$).
Attention weight heatmap showing clinically coherent clusters
  • Not just co-occurrence: Attention heatmaps reveal tight, clinically coherent clusters (e.g., blood gas markers attending to each other for acid-base balance, or creatinine and BUN pairing up). The authors verify this isn't just because those labs are drawn together: the Spearman correlation between co-draw frequency and attention weight is only 0.175.

Key Results

On the held-out test sets, the 2,048-event CTC model achieves the strongest performance across all baselines:

  • MIMIC-IV: 0.8743 Macro F1 and 0.8774 Accuracy (compared to 0.840 Macro F1 for XGBoost, 0.8196 for GenHPF, and 0.7546 for LabTOP).
  • eICU-CRD: 0.8490 Macro F1 and 0.8506 Accuracy (compared to 0.818 Macro F1 for XGBoost, 0.7937 for GenHPF, and 0.7689 for LabTOP).
  • Context Ablation: Extending context from 310 → 610 → 2,048 events improved Macro F1 from 0.8342 → 0.8629 → 0.8743 on MIMIC-IV, and from 0.8132 → 0.8382 → 0.8490 on eICU.

Limitations and Future Work

The authors note that CTC is evaluated exclusively on North American ICU cohorts and relies solely on structured EHR events, ignoring free-text clinical notes. Additionally, because MIMIC-IV and eICU use different lab vocabularies and reference-range conventions, models were trained and evaluated within each dataset rather than transferred across cohorts. Future work includes mapping analytes across institutions for cross-cohort transfer, extending context windows even further for ultra-long-stay patients, and integrating CTC's temporal representations with large language models for multimodal clinical forecasting.

Summary updated

BibTeX
@inproceedings{samuel2026predicting,
  author = {Julian Ezra Samuel and Ryan King and Sadeer Al-Kindi and Bobak J Mortazavi},
  title = {{Predicting Lab Abnormalities from Full EHR Event Sequences with a Causal Temporal Transformer}},
  booktitle = {BHI},
  year = {2026},
  url = {https://openreview.net/forum?id=JXSOtII0Sj},
}
Figure