MedDiff: Generating Electronic Health Records using Accelerated Denoising Diffusion Model

Huan He, Shifan Zhao, Yuanzhe Xi, Joyce C. HoarXiv 2023

Abstract

Due to patient privacy protection concerns, machine learning research in healthcare has been undeniably slower and limited than in other application domains. High-quality, realistic, synthetic electronic health records (EHRs) can be leveraged to accelerate methodological developments for research purposes while mitigating privacy concerns associated with data sharing. The current state-of-the-art model for synthetic EHR generation is generative adversarial networks, which are notoriously difficult to train and can suffer from mode collapse. Denoising Diffusion Probabilistic Models, a class of generative models inspired by statistical thermodynamics, have recently been shown to generate high-quality synthetic samples in certain domains. It is unknown whether these can generalize to generation of large-scale, high-dimensional EHRs. In this paper, we present a novel generative model based on diffusion models that is the first successful application on electronic health records. Our model proposes a mechanism to perform class-conditional sampling to preserve label information. We also introduce a new sampling strategy to accelerate the inference speed. We empirically show that our model outperforms existing state-of-the-art synthetic EHR generation methods.

Introduction

Machine learning in healthcare is often bottlenecked by patient privacy. While sharing real Electronic Health Records (EHRs) is legally and ethically complex, traditional de-identification methods (like adding noise or swapping fields) are increasingly vulnerable to re-identification attacks. Synthetic data generation offers a way out: creating "fake" records that mirror the statistical properties of real patients without actually belonging to anyone.

Until now, the state-of-the-art for this task has been Generative Adversarial Networks (GANs). However, GANs are notoriously finicky to train, prone to "mode collapse," and often require a pre-trained autoencoder to handle high-dimensional data. Diffusion models have revolutionized image and speech synthesis, but their effectiveness on the discrete, high-dimensional, and non-spatial nature of EHR data remained an open question.

Methodology

The authors introduce MedDiff, which adapts the Denoising Diffusion Implicit Model (DDIM) framework for healthcare data through three key innovations:

  1. Modified 1D U-Net: While image-based diffusion models use 2D U-Nets, MedDiff uses a 1D convolutional U-Net designed for patient feature vectors. It incorporates residual blocks, positional embeddings, and increased model depth to capture correlations between neighboring medical codes.
  2. Anderson Acceleration (AA): Diffusion models are traditionally slow because they require hundreds of sequential "denoising" steps. The authors treat the reverse sampling process as a fixed-point iteration. By applying Anderson Acceleration—a numerical technique to speed up the convergence of sequences—they allow the model to reach high-quality samples in far fewer steps.
  3. Conditioned Sampling: To ensure the synthetic data is useful for specific tasks (like predicting a diagnosis), the authors use classifier-guided sampling. A separate classifier is trained on noisy data to "nudge" the diffusion process toward generating records that match a specific target label.
Overview of the forward and reverse diffusion processes in MedDiff.

Experimental Results

The model was evaluated on two publicly available datasets: MIMIC-III (46,520 patients, 1,071 binary features) and Patient Treatment Classification (3,309 patients, 8 continuous features).

Visualization of the forward noise addition and reverse sampling processes.

Key Findings

  • Superior Fidelity: On the MIMIC-III dataset, MedDiff achieved a correlation coefficient ($\rho$) of 0.98 and the lowest Sum of Absolute Errors (SAE) compared to MedGAN, CorGAN, and vanilla DDPM.
  • 2x Speedup: Using Anderson Acceleration, MedDiff converged in approximately 80 iterations, whereas the regular sampling process required 160 iterations to reach the same quality.
  • Downstream Utility: A logistic regression model trained on synthetic data achieved an AUC of 0.742, closely approaching the 0.766 AUC of a model trained on real data.
  • Data Augmentation: The authors found that augmenting a small real dataset with more than 2,000 synthetic records actually improved the performance of a classifier compared to using real data alone.

Conclusion

MedDiff demonstrates that diffusion models can outperform GANs for EHR generation without requiring pre-trained autoencoders. By framing the sampling process as a numerical integration problem, the authors successfully applied Anderson Acceleration to halve inference time.

While MedDiff handles static patient vectors exceptionally well, it does not yet address temporal or longitudinal data. Extending diffusion models to handle the temporal dependencies of hospital visits remains a frontier for future research. Additionally, a "critical mass" of synthetic samples appears necessary for effective data augmentation, as small amounts of synthetic data can lead to a performance dip.

Summary updated

BibTeX
@misc{he2023meddiff,
  author = {Huan He and Shifan Zhao and Yuanzhe Xi and Joyce C. Ho},
  title = {{MedDiff: Generating Electronic Health Records using Accelerated Denoising Diffusion Model}},
  year = {2023},
  eprint = {2302.04355},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2302.04355},
}
Figure