Learning Insulin-Glucose Dynamics in the Wild

Andrew C. Miller, Nicholas J. Foti, Emily B. Fox

Introduction

Managing Type 1 Diabetes (T1D) is a complex, continuous balancing act. Patients must regulate blood glucose levels by dosing insulin to offset carbohydrate intake, aiming to avoid the immediate dangers of hypoglycemia and the long-term complications of hyperglycemia. While technology like Continuous Glucose Monitors (CGMs) and insulin pumps have improved care, accurate forecasting remains a significant challenge due to the highly variable nature of human physiology "in the wild."

The Modeling Gap

Current glucose forecasting tools typically fall into two categories, each with distinct drawbacks:

  1. Physiological Simulators: Models like the FDA-approved UVA/Padova simulator use systems of ordinary differential equations (ODEs) to represent biological processes. While interpretable, they often fail in real-world settings because they assume biological parameters—such as insulin sensitivity—are static. In reality, these factors fluctuate due to stress, illness, or circadian rhythms.
  2. Purely Statistical Models: Deep learning approaches like LSTMs are excellent at capturing patterns in noisy data but often produce "physiologically impossible" predictions. Because they lack an underlying biological framework, they may fail to recognize that an insulin bolus must eventually lower blood glucose.

Methods: The Deep T1D Simulator (DTD-Sim)

To bridge this gap, researchers from Apple developed DTD-Sim, a hybrid model that embeds a physiological simulator within a deep state-space framework.

The DTD-Sim architecture: A hierarchical generative model combining latent linear dynamics with a physiological simulator.

The DTD-Sim architecture treats the parameters of the UVA/Padova simulator as time-varying latent variables. A latent state $z_t$ evolves according to linear Gaussian dynamics, which is then mapped through a neural network to produce the specific simulator parameters $d_t$ (e.g., meal absorption rates or insulin sensitivity) for each time step. This allows the model to maintain biological "common sense" while adapting to the user's changing physiological state. The model is trained using variational inference, leveraging the JAX framework to differentiate through the ODE solver.

Dataset and Evaluation

The study utilized dense, real-world observational data from two T1D participants collected via Apple’s HealthKit. The dataset included 150 days of data per subject, encompassing CGM readings, insulin pump logs, carbohydrate records, and active energy burned (METs). This resulted in over 40,000 data points per participant, providing a robust foundation for testing long-horizon forecasting.

Results

DTD-Sim demonstrates a significant improvement in forecasting accuracy and physiological reliability compared to baseline models.

Comparison of DTD-Sim vs. Static Simulator: DTD-Sim (purple) tracks real-world glucose (black) significantly better than the static model (orange).

Key findings include:

  • Superior Accuracy: At a 6-hour forecast horizon, DTD-Sim reduced Mean Absolute Error (MAE) by 36% compared to an LSTM baseline.
  • Physiological Plausibility: Unlike black-box ML models, DTD-Sim consistently produces forecasts that align with medical expectations. In counterfactual scenarios, such as a hypothetical 50g meal, DTD-Sim correctly predicts a glucose rise followed by a fall after insulin, whereas LSTMs often show spurious or non-responsive correlations.
  • Stability: By constraining the dynamics of the latent state, the authors ensured that long-term forecasts remain stable rather than exploding or vanishing over time.

Conclusion and Future Work

DTD-Sim represents a promising step toward personalized, "in the wild" diabetes management by combining the interpretability of classical physiology with the flexibility of deep learning. While the current study is limited by a small cohort and assumes perfect input data (e.g., accurate carb counting), future iterations could scale to larger populations and incorporate noise models to handle the inherent uncertainty of human-logged data.

Summary updated

BibTeX
@inproceedings{miller2020learning,
  author = {Andrew C. Miller and Nicholas J. Foti and Emily B. Fox},
  title = {{Learning Insulin-Glucose Dynamics in the Wild}},
  booktitle = {MLHC},
  year = {2020},
}
Figure