Abstract
Objective:
To develop a machine learning (ML) framework to identify postprandial glucose responses (PPGR) automatically from continuous glucose monitoring (CGM) data in pregnant adults with gestational diabetes mellitus (GDM).
Methods:
Pregnant adults diagnosed with GDM or impaired glucose tolerance (IGT) wore blinded CGMs and logged mealtimes for up to three 14-day time periods after enrollment. A random forest ML algorithm was applied to identify morning PPGRs from daily CGM profiles, and its performance compared against PPGRs derived using self-reported mealtimes.
Results:
Twenty-one participants provided analyzable data. Relative to self-reported mealtime, the ML algorithm’s predicted mealtimes had an absolute error of a median 30 (interquartile range [IQR]: 20–45) min. Comparing 1-h and 2-h PPGR values from the CGM using self-reported and ML-predicted mealtimes showed a median difference of 8.7 (IQR: 0–22.7) mg/dL and 3.3 (IQR: 0–13.2) mg/dL, respectively, for the two timepoints.
Conclusions:
A random forest ML algorithm accurately identified PPGRs from CGM data in persons with GDM, enabling an automated and convenient approach to monitoring postprandial dysglycemia in this population.
Introduction
Medical nutrition therapy is an essential component of gestational diabetes mellitus (GDM) management, aimed at minimizing large postprandial glucose responses (PPGR). 1 However, current guidelines in GDM require pregnant individuals to monitor PPGRs through four carefully timed manual glucose fingersticks every day, 1 which can be burdensome. 2 This proof-of-concept article demonstrates a machine learning (ML) framework that uses continuous glucose monitoring (CGM) data to automatically characterize PPGRs in individuals with GDM, potentially reducing patient burden while improving the reliability of postprandial glucose assessments.
Methods
Study design and participants
We analyzed data from an observational cohort study in persons diagnosed with GDM or impaired glucose tolerance (IGT) during pregnancy. Participants were recruited from three obstetrics clinics: (1) Department of Obstetrics, Gynecology and Reproductive Sciences at Rutgers-Robert Wood Johnson University Hospital in New Brunswick, NJ; (2) OB-GYN clinic at the New Jersey Medical School—University Hospital in Newark, NJ; and (3) Dhulikhel Hospital in Dhulikhel, Nepal.
Universal GDM screening was conducted at 24–28 weeks of pregnancy with a 50-g 1-h glucose challenge test (GCT). Individuals exceeding the GCT threshold (≥140 mg/dL) underwent a 100-g 3-h oral glucose tolerance test (OGTT). GDM was diagnosed using Carpenter and Coustan criteria, 1 based on two or more abnormal OGTT values (fasting: ≥95 mg/dL; 1-h: ≥180 mg/dL; 2-h: ≥155 mg/dL; 3-h: ≥140 mg/dL). Individuals with one abnormal OGTT value were classified as having IGT. Additional inclusion criteria were age ≥18 years, GDM/IGT diagnosed between 20 and 35 weeks’ gestation, planning to continue treatment at the hospital, and fluent in English or Spanish. Exclusions included type 1 or type 2 diabetes, polycystic ovarian syndrome, or use of glucose-lowering medications unrelated to GDM. Trained research assistants identified eligible participants, explained the study, and obtained written informed consent. The study was approved by Rutgers University Institutional Review Board (Pro2020002231) and the Ethical Review Board of Nepal Health Research Council (Ref number: 735/2019).
Research procedures
Participants attended up to three study visits, wearing a blinded Freestyle Libre Pro CGM sensor (Abbott Diabetes Care, Chicago, IL) and logging their mealtimes for up to 14 days following each visit. The sensor collected glucose data at 15-min intervals. At baseline, information on age, race/ethnicity, pregnancy history, and medical history were also collected. CGM data consisting of paired timestamps and glucose values were extracted using the LibreView software. Mealtimes from paper food logs were extracted manually by study staff.
Statistical methods
ML PPGR estimation algorithm
Training data
A pre-trained random forest ML model was used to identify PPGRs from CGM profiles. 3 The ML model was trained using paired CGM and meal timing data from a public CGM dataset of 30 individuals without diabetes. 4 This dataset has been described in detail previously. Briefly, it consisted of 30 participants who were required to be healthy and free of major organ disease, chronic inflammatory conditions, malignancy, uncontrolled hypertension, eating disorder, history of bariatric surgery, diagnosis of diabetes, use of weight loss or diabetogenic medications, or recent unstable weight. On six different days, participants were asked to consume a standardized meal for breakfast and study staff recorded their mealtimes; three standardized meals were provided on two separate days; the three meals had similar calorie content but differing macronutrient composition.
Model parameters
We reproduced the model architecture and parameters based on a previous study that first proposed a random forest algorithm to identify morning PPGRs. 3 Similar to that study, we built a random forest framework using an ensemble of 20 decision trees 3 to assign a probability that a given 2-h CGM profile segment represents a PPGR. MATLAB’s TreeBagger package was used to build the random forest ML PPGR estimation framework.
Identification of morning PPGRs
In this study, we applied our ML framework to identify morning mealtimes and resultant PPGRs from CGM profiles. We focused on the morning meal in this proof-of-concept study as it occurs after an extensive period of fasting and is least affected by physical activity or other meals. Morning meals were defined as meals occurring between 5 am and noon, while morning PPGR was defined as the 2-h segment of CGM values following the start of the morning meal. We extracted all 2-h CGM segments beginning in the 5 am-noon window and passed them through our ML algorithm, which assigned each segment a probability of being a PPGR. The segment with the highest probability and a peak height over 20 mg/dL was selected as the morning PPGR 5 (Fig. 1A). If no segment met these criteria, no valid morning PPGR was reported for that day.

Overview of ML PPGR analysis framework.
Outcomes
We computed three performance metrics as outcomes comparing the self-reported and ML-predicted PPGRs. The outcomes were computed at a “per-sample” and a “per-participant” level. Per-sample PPGR measures were computed using CGM data from each visit, whereas per-participant PPGR measures were computed by aggregating per-sample PPGR measures across multiple visits for a given participant. The three outcomes of the study are listed below (Fig. 1B):
Results
Participant characteristics
Between July 2021 and June 2024, 34 eligible participants consented to participate in the study. We defined a usable day of data as a day with both CGM data and a morning meal log. Twenty-one participants had at least one usable day of data from at least one visit. Three participants had usable data from all three visits, 12 had usable data from two of their visits, and 6 had usable data from only one visit. In total, visit 1 had usable data from 18 participants, visit 2 from 14 participants, and visit 3 from 7 participants, resulting in a total of 39 usable samples from 21 unique participants (Supplementary Fig. S1). On average, each sample consisted of 10 ± 4 days (mean ± standard deviation) of paired CGM and food log data. Participants were 34 ± 5 years old and enrolled in the study at 28 ± 3 weeks gestation. Eighty-six percent of participants had a diagnosis of GDM, while 14% had a diagnosis of IGT not amounting to GDM (Supplementary Table S1).
Evaluating performance of ML PPGR estimation framework
Performance of Proposed ML PPGR Estimation Algorithm on a per-Sample Level (n = 39)
A sample is defined as CGM data for a participant from a given visit. Reference values for each metric derived using participant’s self-reported morning mealtime and corresponding day’s CGM profile.
AUC, area under the curve; CGM, continuous glucose monitoring; CI, confidence interval; IQR, interquartile range; ML, machine learning; PPGR, postprandial glucose response.
Discussion
Current GDM management relies on manual fingersticks before and after meals, 1 which often results in poor compliance potentially leading to adverse maternal and neonatal outcomes.2,8 CGMs have been shown to be an accurate and acceptable way to monitor glucose levels in persons with GDM9,10 but still require manual mealtime logging to track PPGRs. Our ML-based framework offers an automated approach to tracking PPGRs consistently in fine-grained detail while alleviating the manual burden of precisely timed fingersticks.
Using an average 10 ± 4 days of paired CGM data and self-reported food logs from 21 participants, our ML algorithm identified morning PPGR within a median 30 (IQR: 20–45) min of self-reported mealtimes. This is comparable with state-of-the-art mealtime prediction algorithms, which achieve mealtime prediction accuracy of 25–40 min11–13 but have primarily been tested in nonpregnant patients with type 1 or type 2 diabetes. Our algorithm is the first to achieve similar accuracy in GDM. The ML algorithm had a small bias toward predicting mealtimes earlier than the self-reported mealtimes as opposed to later (57% vs 32% of days). This bias may be explained as follows: since the CGM measures glucose every 15 min, two timestamps on either side of the actual mealtime may be identified as being a PPGR start time by the random forest model. By design, we enforce the selection of the earlier timepoint as the predicted mealtime. This is because, since glucose rises rapidly after meals, a later prediction may miss the early portion of the PPGR leading to an incomplete picture of the full extent of postprandial dysglycemia in a person with GDM. Additionally, the model on average underestimated pre-meal glucose levels by 4.9 mg/dL and overestimated 1-h and 2-h postprandial glucose levels by 8.7 and 3.3 mg/dL, respectively, relative to reference values calculated using self-reported mealtimes. This can also be explained by the earlier prediction bias of our ML algorithm. For fasting glucose levels, the glucose value would have increased between the earlier predicted mealtime and the next sample after 15 min. Similarly, because PPGRs peak between 45 and 60 min after start of meals in people with GDM, 14 1-h and 2-h PPGR values would be on the falling slope of PPGRs, and therefore, the values from the earlier ML-predicted times would be higher than those from the later self-reported mealtimes. Another contributor to the mealtime prediction error could be due to the intrinsic lag time of CGM sensors in responding to surge in postprandial glucose. 15 Future studies incorporating highly controlled feeding times could help tease out the different sources of error made by the AI algorithm. Nevertheless, the algorithm’s ability to estimate PPGR parameters with reasonable accuracy highlights its clinical potential for automated PPGR monitoring in persons with GDM.
Strengths of this study include a diverse sample from the United States and Nepal, CGM collection at three visits post-GDM diagnosis, and detailed self-reported food logs for evaluation. Limitations include small sample size and potential errors in self-reported mealtimes. We also did not account for physical activity and sleep, which prior studies have shown impact morning PPGRs.16,17 The random forest model was trained on PPGRs in nonpregnant adults without diabetes and therefore lacks knowledge on pregnancy-specific PPGR patterns. Fine-tuning the model using PPGR data from pregnant women with GDM using techniques such as transfer learning 17 can help improve the performance further.
Conclusions
In conclusion, our ML-based framework showed promising performance in estimating morning mealtimes and associated PPGR characteristics using CGM data. If successfully validated in larger cohorts, our ML approach offers an automated and convenient adjunct to self-monitoring of blood glucose for GDM management.
Footnotes
Authors’ Contributions
S.B.: Conceptualization, methodology, software, formal analysis, writing—original draft, visualization, supervision, and funding acquisition. T.S., E.M, V.M, L.B., S.W., and T.R.: Investigation, resources, data curation, and writing—review and editing. D.U.: Software, formal analysis, data curation, and visualization. C.P., H.H., and L.-J.L.: Writing—review and editing. S.R.: Supervision, project administration, funding acquisition, and writing—review and editing. All authors approved the article. S.B. is the guarantor of this work and, as such, had full access to all the data in the study and takes responsibility for the integrity of the data and the accuracy of the data analyses.
Author Disclosure Statement
The authors declare no competing interests.
Funding Information
This research was supported by the Rutgers SHP Dean’s Intramural Grant. S.B. was supported by the American Heart Association’s Second Century Early Faculty Independence Award (24SCEFIA1252353).
Abbreviations Used
References
Supplementary Material
Please find the following supplemental material available below.
For Open Access articles published under a Creative Commons License, all supplemental material carries the same license as the article it is associated with.
For non-Open Access articles published, all supplemental material carries a non-exclusive license, and permission requests for re-use of supplemental material or any part of supplemental material shall be sent directly to the copyright owner as specified in the copyright notice associated with the article.
