Flexible-Window Predictions on Electronic Health Records

Mehak Gupta, Raphael Poulain, Thao-Ly T. Phan, H. Timothy Bunnell, Rahmatollah Beheshti

Predictive modeling in healthcare often feels like trying to fit a square peg into a round hole. While patient histories are long, irregular, and messy, most machine learning models require "fixed windows"—for example, "look at exactly 12 months of data to predict the next 6 months." If a clinician wants to look at two years of data instead, or predict five years into the future, they usually have to train an entirely new model.

In a paper presented at AAAI-22, researchers from the University of Delaware and Nemours Children’s Health introduce a more elegant solution: a flexible-window prediction framework that can be trained once and then queried for any timeframe.

The Challenge of EHR Data

Electronic Health Record (EHR) data is notoriously difficult to work with. Patients visit doctors at irregular intervals, and their medical histories vary wildly in length. Most existing AI models handle this by "binning" data into fixed timeframes, which creates three major headaches:

  1. Data Waste: Patients who don't fit the specific window (e.g., they only have 11 months of data for a 12-month model) are often discarded.
  2. Rigidity: A model trained for a 6-month prediction cannot easily be used for a 2-year prediction.
  3. Missingness: EHRs are full of gaps where no data was recorded, which standard models struggle to "fill in" accurately.

The authors sought to create a "train-once, use-anywhere" model that views a patient's journey as a continuous sequence rather than a static snapshot.

Proposed Framework: Seq-Gen and GAN

The core of the approach is a Sequence Generator Network (Seq-Gen) paired with a Discriminator (Dis) in a Generative Adversarial Network (GAN) framework. This architecture allows the model to treat EHR prediction as a generative task, effectively imputing missing values during training.

The Seq-Gen architecture uses an encoder-decoder with attention, paired with a discriminator to handle missing data.
  • The Generator (Seq2Seq): This uses an Encoder-Decoder architecture with Gated Recurrent Units (GRUs). The Encoder processes a sequence of patient features (conditions, medications, and age). An Attention Mechanism identifies which past visits are most relevant. The Decoder then generates a sequence of predicted labels for the entire timeline.
  • The Discriminator: To handle the fact that many time points in the training data lack labels (e.g., missing BMI records), the authors added a discriminator. Its job is to distinguish between "real" observed labels and the "fake" labels generated by the model. This forces the generator to produce predictions that match the overall distribution of the real data.
  • Flexibility: Because the model is trained to output a sequence, a user can provide any amount of history as input, and the model can continue the sequence to provide predictions for any future point without retraining.

Experimental Setup and Datasets

The researchers evaluated their model on two massive, distinct populations for the task of obesity prediction (using BMI-based labels across 40 three-month bins representing a decade of health data):

  • All of Us Research Program: Over 34,000 adult participants in the US with at least 10 years of medical history.
  • Nemours Pediatric: 70,000 children (ages 1–10) with a minimum 10-year history.

Key Results and Clinical Insights

The proposed model consistently outperformed popular EHR baselines like RETAIN, tLSTM, and Dipole. On the All of Us dataset (males), the proposed model achieved an AUROC of 0.70, significantly higher than RETAIN (0.60) and tLSTM (0.62). Crucially, the model maintained high performance across various "Observation/Prediction" splits (e.g., 3/7 years, 5/5 years, and 7/3 years) without needing to be retrained for each scenario.

Beyond accuracy, the attention analysis revealed fascinating clinical insights. For adults, the model focused heavily on the very beginning of the observation window. For children, it focused more on the end of the window, suggesting that recent changes are more predictive of obesity in developing children than in adults.

Attention heatmaps show that the model prioritizes different time periods for adults versus pediatric patients.

Conclusion

By removing the need for retraining, this approach lowers the barrier for deploying AI in clinics. A single model could power a dashboard where a doctor manually slides a "window" to see how a patient's risk changes over different future horizons. While future work is needed to incorporate high-dimensional data like lab results and clinical notes, this framework represents a significant step toward making EHR models as dynamic as the patients they serve.

Summary updated

Abstract

Various types of machine learning techniques are available for analyzing electronic health records (EHRs). For predictive tasks, most existing methods either explicitly or implicitly divide these time-series datasets into predetermined observation and prediction windows. Patients have different lengths of medical history and the desired predictions (for purposes such as diagnosis or treatment) are required at different times in the future. In this paper, we propose a method that uses a sequence-to-sequence generator model to transfer an input sequence of EHR data to a sequence of user-defined target labels, providing the end-users with ``flexible'' observation and prediction windows to define. We use adversarial and semi-supervised approaches in our design, where the sequence-to-sequence model acts as a generator and a discriminator distinguishes between the actual (observed) and generated labels. We evaluate our models through an extensive series of experiments using two large EHR datasets from adult and pediatric populations. In an obesity predicting case study, we show that our model can achieve superior results in flexible-window prediction tasks, after being trained once and even with large missing rates on the input EHR data. Moreover, using a number of attention analysis experiments, we show that the proposed model can effectively learn more relevant features in different prediction tasks.
BibTeX
@inproceedings{gupta2022flexible,
  author = {Mehak Gupta and Raphael Poulain and Thao-Ly T. Phan and H. Timothy Bunnell and Rahmatollah Beheshti},
  title = {{Flexible-Window Predictions on Electronic Health Records}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2022},
  doi = {10.1609/aaai.v36i11.21520},
}
Figure