BiteNet: Bidirectional Temporal Encoder Network to Predict Medical Outcomes

Xueping Peng, Guodong Long, Tao Shen, Sen Wang, Jing Jiang, Chengqi Zhang

Electronic Health Records (EHRs) contain rich, hierarchical data about a patient's medical journey. However, traditional models based on Recurrent Neural Networks (RNNs) often struggle with long-term dependencies and the irregular time intervals characteristic of clinical visits. This paper introduces BiteNet, a novel bidirectional temporal encoder network that relies entirely on self-attention mechanisms to predict medical outcomes like hospital readmissions and future diagnoses.

The Challenge of Longitudinal EHR Data

EHR data is inherently hierarchical, structured from specific medical codes to individual visits, and finally to the overall patient journey. Predicting future outcomes—such as readmission risk or next-visit diagnoses—requires embedding this complex, irregular, and time-stamped data into a mathematical vector.

Historically, RNNs have been the standard for modeling sequential visits. However, they suffer from "forgetfulness" and vanishing gradients as medical histories lengthen. Furthermore, standard attention models (like the vanilla Transformer) treat sequences as evenly spaced, failing to account for the highly irregular time gaps (ranging from days to years) between medical visits.

The BiteNet Architecture

To overcome the limitations of recurrence, BiteNet utilizes an end-to-end architecture based solely on attention mechanisms. By explicitly modeling temporal order and time gaps, it provides a more robust representation of the patient journey.

The BiteNet architecture, featuring hierarchical attention layers and interval encoding.

Key Innovations

  • Masked Encoder (MasEnc): A novel multi-head self-attention block designed for temporal data. It uses specific masking strategies (forward, backward, and diagonal-disabled) to enforce temporal ordering. For instance, a forward mask ensures a visit only attends to past events, preventing data leakage from the future.
  • Interval Encoding: To handle irregular gaps, BiteNet calculates the days elapsed between a visit and the patient's first recorded encounter. This temporal interval is processed through a learned lookup table and added to the visit embedding, giving the model an explicit sense of time.
  • Hierarchical Attention Pooling: The model mirrors EHR structure by first using attention to compress medical codes into a "visit" representation, and then using another layer to compress visits into a final "patient journey" embedding.

Experimental Evaluation

The authors evaluated BiteNet using MIMIC-III, a large-scale open-source dataset of ICU patients. They focused on two sub-datasets:

  1. Dx: Diagnosis codes only.
  2. Dx&Tx: Both diagnosis and procedure (treatment) codes.

BiteNet was compared against strong baselines including RNN, BRNN, RETAIN, Deepr, Dipole, and SAnD.

Key Results and Insights

BiteNet consistently outperformed baselines in both supervised and unsupervised tasks. For readmission prediction on the Dx&Tx dataset, it achieved a PR-AUC of 0.3357, surpassing the best baseline (BRNN at 0.3270). For diagnosis prediction, it reached a Precision@30 of 0.8289.

Precision@20 performance across varying sequence lengths (number of visits) on the Dx&Tx dataset.

Critical Findings

  • Robustness to Long Histories: As shown in the performance curves, BiteNet maintains high predictive accuracy even as the sequence of patient visits grows (tested up to 16 visits). In contrast, traditional RNN models see significant performance degradation on these longer sequences.
  • The Importance of Time: Ablation studies revealed that "Interval Encoding" is critical for predicting hospital readmissions. Knowing when events happened is as vital as knowing what happened.
  • Inherent Explainability: The hierarchical attention weights allow clinicians to visualize which past visits or specific codes (e.g., an old "end-stage renal disease" diagnosis) most heavily influenced a specific prediction.
  • Impact of Procedures: Adding procedure codes (Dx&Tx) improved readmission predictions across all models, though it had a mixed effect on future diagnosis prediction for some baselines.

Conclusion

By replacing recurrent bottlenecks with masked self-attention and explicit interval encoding, BiteNet offers a state-of-the-art approach to modeling complex patient journeys. While the current study focused on ICU data and common medical codes, future work may involve integrating unstructured clinical notes and lab values to further enhance predictive power.

Summary updated

BibTeX
@inproceedings{peng2021bitenet,
  author = {Xueping Peng and Guodong Long and Tao Shen and Sen Wang and Jing Jiang and Chengqi Zhang},
  title = {{BiteNet: Bidirectional Temporal Encoder Network to Predict Medical Outcomes}},
  booktitle = {Proceedings / IEEE International Conference on Data Mining. IEEE International Conference on Data Mining},
  year = {2021},
  url = {https://openreview.net/forum?id=7cPa5yNm4a},
}
Figure