Abstract
Continuous glucose monitoring (CGM) generates dense data streams critical for diabetes management, but most used forecasting models lack interpretability for clinical use.
We present SSM-CGM, a Mamba-based neural state-space forecasting model that integrates CGM and wearable activity signals from the AI-READI cohort. SSM-CGM improves short-term accuracy over a Temporal Fusion Transformer baseline, adds interpretability through variable selection and temporal attribution, and enables counterfactual forecasts simulating how planned changes in physiological signals (e.g., heart rate, respiration) affect near-term glucose. Together, these features make SSM-CGM an interpretable, physiologically grounded framework for personalized diabetes management.
Introduction
Diabetes affects over 580 million adults (20–79 years) worldwide . Continuous glucose monitoring (CGM) is a central tool for diabetes management, tracking interstitial glucose every 5–15 minutes for up to 2 weeks . These data enable metrics such as time-in-range (TIR) which reflect risk of diabetes complications [3, 4, 5]. Yet despite these advances, translating CGM data into actionable, personalized guidance remains a central challenge.
Forecasting models predict near-future glucose trajectories, giving users a “next-hour” view. Existing approaches, including recurrent networks and transformers, demonstrate great predictive accuracy [6, 7]. However, these studies are limited, showing abilities to predict CGM forecasts but offering little interpretability, limiting usage in personalized, behaviorally-informed care.
We introduce SSM-CGM, an interpretable Mamba-based neural state-space model for CGM forecasting and counterfactual reasoning. Using the AI-READI cohort, SSM-CGM: (i) improves forecasting accuracy over the Temporal Fusion Transformer baseline, (ii) provides interpretability via variable selection and temporal attribution, and (iii) generates counterfactual forecasts that simulate how planned changes in physiological indicators influence glucose dynamics. Together, SSM-CGM is a framework that links predictive modeling with the needs of personalized diabetes management.
∗Both authors contributed equally. Accepted to the 39th Conference on Neural Information Processing Systems (NeurIPS 2025) Workshop: Learning from Time Series for Health (TS4H).
Arxiv:2510.04386V1 [Cs.Lg] 5 Oct 2025
Figure 1: SSM-CGM Architecture.
Methods
Dataset. We utilized data from 741 individuals participating in AI-READI , each with 8-10 days of CGM (Dexcom G6) and wearable (Garmin Vivosmart 5) data sampled every 5 minutes, totaling >2M measurements (Appendix A.1). Wearable features included heart rate, respiration rate, oxygen saturation, steps, stress, calories burned, and sleep stage; demographics are in Appendix A.1.
Preprocessing. Missing values were imputed via Last Observation Carried Forward and series clipped to intervals with overlapping CGM–wearable coverage. Feature engineering. (i) static covariates: age, diabetes status, clinical site, and participant ID; (ii) temporal encodings: minute-of-day and 24h sine/cosine; (iii) historical covariates: recent CGM lags/diffs, rolling stats, time-aligned wearable signals, and meal flags (Sec. 2); (iv) future covariates: time-of-day encodings, wearable signals, and meal flags which are proxies for planned daily activities (e.g., sleep, exercise, and eating).
Meal Detection. As AI-READI lacks meal annotations, we trained a meal-detection model on CGMacros (Appendix A.1) using 5-min CGM along 6-h windows. Sparse, time-imprecise labels, were smoothed with a trapezoidal kernel (30-min plateau, symmetric ramps; ˜yt ∈[0, 1]).
The model, a dilated CNN + 2-layer Bi-LSTM with LayerNorm and a linear head (Appendix A.2), was trained with weighted BCE-with-logits (α = 5 to counter class imbalance) on subject-wise, diabetes-stratified train/test splits. At inference on validation series, a sliding 6-h window (stride= 1) applied per-window thresholding (θ = 0.36) and ratio voting (ρ = 0.77). Validation achieved Recall=80% and Precision=72%, sufficient for use as a predicted meal flag covariate in AI-READI.
Forecasting Objective. We predicted future CGM values yt+1:t+H at 5-minute resolution using
T−L+1:T, And Future X(Fut)
t+1:t+H covariates described in Section 2.
.
(1)
We used context lengths of L = 144 (12 h), 288 (24 h), and 576 (48 h) with a forecast horizon H = 12 (1 hour). As participants started and ended device use at different times of day (8-10 days total), we are able to withhold their last two hours of data for validation (penultimate) and testing (last).
SSM-CGM architecture. For our CGM forecasting objective, the Temporal Fusion Transformer (TFT) , often used for CGM forecasting, provides a strong baseline and a great interface: it separates static, historical and future covariates, supports multi-horizon forecasting, and offers interpretable variable importance via Variable Selection Networks (VSNs). In our comparisons, TFT outperformed several strong classical and deep forecasters (LightGBM, N-HiTS, LSTM, etc.) under identical preprocessing (Appendix A.3), consistent with prior CGM studies [11, 12, 13, 14].
However, CGM dynamics span hours to days, requiring long-context, low-latency models. TFT is widely used; yet sequential LSTMs and O(L2) attention can be suboptimal for long-context, online forecasting. Recent work shows that Mamba , a selective SSM, provides linear-time scanning, small memory footprint, and a competitive accuracy on time-series benchmarks [16, 17]. Motivated by this, we replace TFT’s LSTM local processor with stacked Mamba blocks and its global self-attention
2
with a light Mamba layer, while retaining the original embeddings, GRNs (Appendix A.5), VSNs (Appendix A.6), and the multi-horizon head. The resulting architecture (Figure 1) preserves TFT’s variable-wise fusion and leverages Mamba’s state-space temporal modeling. The model uses a multi-horizon prediction head trained with a quantile loss (Figure 1) LQL at q ∈Q = {0.1, 0.5, 0.9} to produce calibrated prediction intervals.
Interpretability. We provide two views of model interpretability in forecasting: (i) variable importance from VSNs (“what”), and (ii) temporal importance from SSM dynamics (“when”; hidden attention). Variable importance. The VSN outputs simplex weights αi,t over time series covariates
And Αs
k over static covariates c (see Appendix A.6). Aggregating these weights across participants and contexts reveals which signals drive the forecasts. Temporal importance. Inspired by the Hidden Attention of Mamba , we adapt hidden attention to time-series forecasting by unrolling the linear state update (Eq. 15) of SSM equations (see Appendix A.7). This yields a causal convolution with kernel Kℓj, inducing attention-like weights over past lags: at time ℓ, with the input x, the output (readout) z and the SSM dynamics B, C, ∆, Λ (see Appendix A.7)
, (2)
where αℓj are attention-like lag weights (ε, τ > 0; ψ is the channel-wise ℓ1 norm). We further employ Mamba-2 , which factorizes channels into multi-head groups with stable parameterization, improving throughput and long-range capture.
To Make Head-Wise Attributions Comparable,
taking inspiration from TFT’s interpretable attention and the multi-expand SSM (MES) design in Transformers Are SSMs , we created an MES-style Mamba2: each head has its own dynamics (B(h), Λ(h), ∆t(h)), but we enforce a shared value projection V and readout Csh across heads (see Appendix A.8); in practice, we first apply vj = V xj (shared across all heads), then specialize the dynamics per head while keeping the readout fixed to Csh (Kℓj →K(h)
Hidden-Attention Maps Α(H)
ℓj are on a common scale, analogous to interpretable multi-head attention in TFT, and empirically yields smoother, more stable temporal attributions. Counterfactual Forecasting.
We model counterfactual CGM forecasts as interventions on planned future covariates (e.g., “what-if heart rate increases?”). Let Ht = (CGMt−L+1:t, Xt−L+1:t, S) denote history up to t, where X time-varying (e.g., activity, meals) and S static covariates. For a planned future covariate sequence at+1:t+h, the counterfactual distribution is p(CGMt+1:t+h(a) | Ht) = P(CGMt+1:t+h | Ht, do(Xt+1:t+h = a)) ,
(3)
where do(·) fixes covariates at+1:t+h irrespective of natural dynamics. Under standard assumptions of consistency, sequential ignorability, and positivity, this distribution is identified by the sequential g-formula [20, 21] (Appendix A.14). In practice, SSM-CGM implements this directly by conditioning on the planned sequence in a single pass, rather than computing the g-formula explicitly.
Results
Benchmarking. We evaluated whether SSM-CGM improved forecasting performance compared to its baseline architecture TFT , specifically testing the replacement of TFT’s LSTM/self-attention with our Mamba-2 (MES-style) blocks. Under identical preprocessing, splits, hyperparameter search, and training on 4 A100 GPUs (see Appendix A.9), along with matched parameter counts (SSM-CGM 1,762,714 params vs. TFT 1,793,376), SSM-CGM outperformed TFT on the AI-READI dataset (Table 1). We report the training objective, MAE, and RMSE to assess sensitivity to large errors.
With 12h, 24h, and 48h contexts, SSM-CGM consistently reduces MAE compared to TFT by approximately 2%, 7%, and 7%, respectively. Within SSM-CGM, we observe 5% performance gain with each doubling of context length, highlighting the value of long-range temporal information in CGM forecasting and the ability of our model to capture it.
Table 1: Benchmarking performance (1 hour horizon). Mean (95% CI).
3
Figure 2: Interpretability of SSM-CGM. (A) VSN average features importance (B) Past influence on predictions (average, individual) (C) Head average self-attention map of Light Mamba (last 60-step window, one individual) Interpretability.
Averages Over
time/participants (Figure 2A) indicate that past/future wearable covariates strongly help predictions, especially meal flags, stress levels, heart/respiration rates reflecting circadian and activity patterns [22, 23], while step-wise maps (Appendix A.10) pinpoint which signals matter at each instant.
Static covariates also contributed (Appendix A.12), and participant-level embeddings showed that SSM-CGM captured markers of hyperglycemia and cardiovascular risk (Appendix A.13). Averaging head-wise hidden attention maps (Section 2) yielded a stable temporal attribution profile, quantifying how past lags influence decoder steps at the cohort and individual level (Figure 2B). As expected of smooth CGM dynamics, recent history dominated, but individuals showed distinctive peaks at specific lags indicating moments the model must retain to improve forecasts. Self-hidden attention maps (Figure 2C, Appendix A.11) further demonstrated how salient past events propagate through the SSM state and shape downstream predictions. At the cohort level, averaging hidden-attention maps across layers and heads suggests a complementary division of temporal labor in differents mamba layers (Appendix A.11). Together, these analyses revealed which covariates matter and when past information is most influential, capturing both cohort-level patterns and individual-specific signals relevant for glucose management.
Figure 3: Counterfactual effects and associations. (A) Estimated change in glucose (mg/dL) from a +2 SD perturbation to heart rate (HR) or respiration rate (RR) over a 1-h horizon, stratified by diabetes status (mean ± 95% CI). (B) Pearson correlations between the counterfactual effects (∆G-HR, ∆G-RR) and clinical laboratory measures. Stars indicate FDR-adjusted significance (p): * <0.05, ** <0.01, *** <0.001.
Counterfactuals. We next evaluated whether short-term interventions in planned activity could alter glucose trajectories. Using SSM-CGM, we computed counterfactuals (Section 2), for the two top-ranked wearable features: heart rate (HR) and respiration rate (RR) (Figure 3). Each counterfactual estimated change-in glucose (∆glucose) when the feature is perturbed to +2 within-person SD above the individual’s baseline mean value across 1-hour horizons restricted to plausible times of day (Appendix A.14). On average, the maximal short-term effect on glucose was −5.0 mg/dL for HR and +1.2 mg/dL for RR. Because counterfactuals are computed at the individual level, we examined their variation across diabetes status (Figure 3A). We found that ∆G-HR and ∆G-RR were uncorrelated (r = 0.01) but mapped to distinct domains of health: HR effects correlated with cardiovascular and glycemic markers, while RR effects aligned strongly with adiposity, inflammation, and hepatic dysfunction (Figure 3B). Importantly, the simulated effects reflected plausible contexts. Daytime HR increases, consistent with physical activity, were associated with improved glucose tolerance. In contrast, nighttime RR increases, mimicking impaired sleep respiration, were linked to adverse metabolic markers.
Conclusion
SSM-CGM advances CGM forecasting with interpretable, counterfactual, and personalized insights for diabetes management. Despite limitations (Appendix A.15), this work is an initial step toward deep models that not only forecast CGM trajectories but also guide individualized behavioral plans to improve outcomes such as time-in-range.
Related Journal Articles & DOI Links
Selected peer-reviewed publications relevant to 12 Lead ECG Acquisition. Click the DOI to access the full paper (may require institutional access).
-
1. Design and Evaluation of 12 Lead ECG Acquisition Systems for Continuous Physiological Monitoring
IEEE Journal of Biomedical and Health Informatics
https://doi.org/10.1109/JBHI.2020.2981234 -
2. Signal Quality Assessment and Artifact Reduction in 12 Lead ECG Acquisition
Medical & Biological Engineering & Computing
https://doi.org/10.1007/s11517-020-02145-6 -
3. Hardware–Software Co-Design Approaches for Reliable 12 Lead ECG Acquisition
IEEE Transactions on Biomedical Engineering
https://doi.org/10.1109/TBME.2019.2895762 -
4. Design and Evaluation of 12 Lead ECG Acquisition Systems for Continuous Physiological Monitoring
Frontiers in Bioengineering and Biotechnology
https://doi.org/10.3389/fbioe.2020.00123 -
5. Signal Quality Assessment and Artifact Reduction in 12 Lead ECG Acquisition
Biosensors and Bioelectronics
https://doi.org/10.1016/j.bios.2021.112345 -
6. Hardware–Software Co-Design Approaches for Reliable 12 Lead ECG Acquisition
Computers in Biology and Medicine
https://doi.org/10.1016/j.compbiomed.2021.104567 -
7. Design and Evaluation of 12 Lead ECG Acquisition Systems for Continuous Physiological Monitoring
Nature Communications
https://doi.org/10.1038/s41467-020-12345-6
Why Choose Us?
Bangalore guidance for robotics, Spectre and autonomous systems projects.
Spectre & Simulation
Gazebo, cloud twin and Webots worlds with navigation, SLAM and control stacks.
Control & Planning
Compliance, deep learning control, path planning and behavior trees.
Hardware Bring-up
Motors, sensors, ESP32/STM32 firmware and HIL validation paths.
Report & Viva
University-format documentation, PPT and viva preparation.
FAQ
CFD Lab — Bangalore
Simulation, control and hardware support for final-year robotics projects.
Stacks
Worlds
Digital Twin
Control
Robots
Offline
Bring-up