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, high-stakes balancing act. Patients must carefully calibrate insulin intake to prevent high blood sugar (hyperglycemia) while avoiding the life-threatening risks of dangerously low levels (hypoglycemia). Accurate glucose forecasting is essential for automating this process, yet existing approaches often fall into two limited camps: interpretable but "brittle" physiological models that struggle with real-world variability, and flexible but "unconstrained" machine learning models that can produce biologically impossible predictions.

Researchers from Apple have developed DTD-Sim (Deep T1D Simulator), a hybrid model that fuses classical biological simulations with deep state-space models. By allowing a machine learning model to "drive" the time-varying parameters of a biological simulator, the team achieved significantly more accurate long-term forecasts that remain physiologically plausible even in noisy, real-world conditions.

Methods: The DTD-Sim Architecture

The core innovation of DTD-Sim is its "fused" architecture, which combines the strengths of domain-specific knowledge with the flexibility of deep learning.

The DTD-Sim architecture fuses a deep state-space model (top) with a physiological ODE simulator (bottom) via a neural network link.
  • The Backbone: The model utilizes the FDA-approved UVA/Padova physiological simulator, which uses Ordinary Differential Equations (ODEs) to describe glucose-insulin interactions.
  • The Driver: A Deep State-Space Model (SSM) treats the simulator's parameters—such as insulin sensitivity or carbohydrate absorption rates—as time-varying latent variables rather than fixed constants.
  • The Link: A neural network maps the latent states of the SSM to the specific parameters of the ODE simulator.

This structure allows the model to learn how a patient's biology shifts throughout the day (e.g., capturing the "dawn phenomenon") while ensuring the final output always adheres to realistic biological trajectories.

Datasets and Training

The study utilized real-world observational data from two T1D participants collected via Apple’s HealthKit framework. The data streams included Continuous Glucose Monitor (CGM) readings, insulin pump logs (basal and bolus), carbohydrate logs, and energy expenditure (METs).

Data was collected over 150 days per participant, sampled every five minutes, resulting in over 40,000 data points per person. The researchers used the first 120 days for training and validation, reserving the final 30 days for testing. To ensure stable optimization, they employed Variational Inference with a non-centered parameterization.

Key Results

DTD-Sim demonstrates that "static" physiological models are insufficient for fitting real-world data because the "noise" in the wild is often actually unobserved biological change. By allowing parameters to drift via an ML sequence model, DTD-Sim captures these shifts effectively.

A comparison of glucose predictions shows that DTD-Sim (purple) closely tracks actual glucose levels (black), whereas static simulations (dashed orange) fail to capture real-world fluctuations.

Key performance metrics include:

  • Long-Horizon Superiority: While simple models like ARMA or LSTMs perform well for 15–30 minute "nowcasts," DTD-Sim dominates at longer horizons. At the six-hour mark, DTD-Sim improved upon the baseline LSTM by 36% in Mean Absolute Error (MAE).
  • Inductive Bias: Unlike pure statistical models that lack a causal understanding of insulin, DTD-Sim "knows" that insulin must eventually lower glucose, leading to more stable and reliable long-term predictions.
  • Counterfactual Sanity: In "what if" scenarios (e.g., simulating a large meal without insulin), DTD-Sim produced spikes matching biological expectations, whereas LSTMs often produced nonsensical or delayed responses.

Limitations and Future Work

While promising, the study was limited to a small cohort of two individuals. Future research will require a larger, more diverse group to generalize these findings. Additionally, the current model assumes user-logged carbohydrate and insulin data are perfectly accurate; future iterations could incorporate uncertainty modeling for these inputs. The authors also suggest integrating more data streams, such as heart rate or sleep stages, to further refine the latent state-space model's understanding of the user's physiological environment.

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