Optimizing Input Window Length and Feature Requirements for Machine Learning-Based Postprandial Hyperglycemia Prediction
Abstract
Continuous glucose monitoring systems currently generate alerts only after blood glucose thresholds are breached, limiting their utility for proactive diabetes management. Predicting postprandial glucose excursions before they occur requires determining the optimal amount of historical data and identifying which features contribute most to prediction accuracy. This study systematically evaluates how the length of the pre-meal observation window and feature composition affect machine-learning predictions of hyperglycemia events 60 minutes after eating. We analyzed 1,642 meal events from 45 adults wearing continuous glucose sensors, constructing features from pre-meal glucose trajectories, meal macronutrients, time of day, and health status. Four observation windows (15, 30, 45, 60 minutes) and three feature sets (all features, glucose-only, meal-only) were evaluated using Random Forest, XGBoost, and CatBoost with 5-fold group cross-validation. CatBoost with a 30-minute window achieved the best performance: 72.6% F1-macro, 79.6% accuracy, and 64.0% recall for hyperglycemia detection. Extending windows beyond 30 minutes did not yield consistent benefits, whereas 15-minute windows yielded comparable results. Glucose trajectory features alone retained 94% of full model performance (68.5% F1-macro), whereas meal composition alone proved insufficient (59.4% F1-macro). These findings demonstrate that recent glucose history dominates short-term prediction, enabling practical real-time systems with minimal data requirements. A 30-minute observation window with glucose and meal features offers an effective balance between prediction accuracy and system responsiveness.
Downloads
References
“IDF Diabetes Atlas 10th edition.” [Online]. Available: www.diabetesatlas.org
“2. Classification and Diagnosis of Diabetes: Standards of Medical Care in Diabetes—2022,” Diabetes Care, vol. 45, pp. S17–S38, Jan. 2022, doi: 10.2337/dc22-S002.
H. Ali, I. K. Niazi, D. White, M. N. Akhter, and S. Madanian, “Comparison of Machine Learning Models for Predicting Interstitial Glucose Using Smart Watch and Food Log,” Electronics (Switzerland), vol. 13, no. 16, Aug. 2024, doi: 10.3390/electronics13163192.
A. E. S. El-Bashbishy and H. M. El-Bakry, “Pediatric diabetes prediction using deep learning,” Sci Rep, vol. 14, no. 1, Dec. 2024, doi: 10.1038/s41598-024-51438-4.
T. Prioleau, A. Bartolome, R. Comi, and C. Stanger, “DiaTrend: A dataset from advanced diabetes technology to enable development of novel analytic solutions,” Sci Data, vol. 10, no. 1, Dec. 2023, doi: 10.1038/s41597-023-02469-5.
A. Gudiño-Ochoa et al., “Enhanced Diabetes Detection and Blood Glucose Prediction Using TinyML-Integrated E-Nose and Breath Analysis: A Novel Approach Combining Synthetic and Real-World Data,” Bioengineering, vol. 11, no. 11, Nov. 2024, doi: 10.3390/bioengineering11111065.
L. Vu et al., “Predicting Nocturnal Hypoglycemia from Continuous Glucose Monitoring Data with Extended Prediction Horizon.”
X. Wang, Z. Sun, H. Xue, and R. An, “Artificial Intelligence Applications to Personalized Dietary Recommendations: A Systematic Review,” Jun. 01, 2025, Multidisciplinary Digital Publishing Institute (MDPI). doi: 10.3390/healthcare13121417.
B. O. Olorunfemi et al., “Efficient diagnosis of diabetes mellitus using an improved ensemble method,” Sci Rep, vol. 15, no. 1, Dec. 2025, doi: 10.1038/s41598-025-87767-1.
H. Seto et al., “Gradient boosting decision tree becomes more reliable than logistic regression in predicting probability for diabetes with big data,” Sci Rep, vol. 12, no. 1, Dec. 2022, doi: 10.1038/s41598-022-20149-z.
B. Lu, Y. Cui, P. Belsare, C. Stanger, X. Zhou, and T. Prioleau, “Mealtime prediction using wearable insulin pump data to support diabetes management,” Sci Rep, vol. 14, no. 1, Dec. 2024, doi: 10.1038/s41598-024-71630-w.
Y. Fan, “Diabetes diagnosis using a hybrid CNN LSTM MLP ensemble,” Sci Rep, vol. 15, no. 1, Dec. 2025, doi: 10.1038/s41598-025-12151-y.
R. A. Fraser, R. J. Walker, J. A. Campbell, O. Ekwunife, and L. E. Egede, “Integration of artificial intelligence and wearable technology in the management of diabetes and prediabetes,” NPJ Digit Med, vol. 8, no. 1, Dec. 2025, doi: 10.1038/s41746-025-02036-9.
Q. Zhao et al., “Chinese diabetes datasets for data-driven machine learning,” Sci Data, vol. 10, no. 1, Dec. 2023, doi: 10.1038/s41597-023-01940-7.
X. Xiong, Y. Xue, Y. Cai, J. He, and H. Su, “Prediction of personalised postprandial glycaemic response in type 1 diabetes mellitus,” Front Endocrinol (Lausanne), vol. 15, 2024, doi: 10.3389/fendo.2024.1423303.
C. Mosquera-Lopez et al., “Enabling fully automated insulin delivery through meal detection and size estimation using Artificial Intelligence,” NPJ Digit Med, vol. 6, no. 1, Dec. 2023, doi: 10.1038/s41746-023-00783-1.
M. S. Haleem et al., “A multimodal deep learning architecture for predicting interstitial glucose for effective type 2 diabetes management,” Sci Rep, vol. 15, no. 1, Dec. 2025, doi: 10.1038/s41598-025-07272-3.
C. M. L. Hughes, Y. Zhang, A. Pourhossein, and T. Jurasova, “A comparative analysis of binary and multi-class classification machine learning algorithms to detect current frailty status using the English longitudinal study of ageing (ELSA),” Frontiers in Aging, vol. 6, 2025, doi: 10.3389/fragi.2025.1501168.
B. Theodorou, B. Danek, V. Tummala, S. P. Kumar, B. Malin, and J. Sun, “Improving medical machine learning models with generative balancing for equity and excellence,” NPJ Digit Med, vol. 8, no. 1, Dec. 2025, doi: 10.1038/s41746-025-01438-z.
M. Salmi, D. Atif, D. Oliva, A. Abraham, and S. Ventura, “Handling imbalanced medical datasets: review of a decade of research,” Artif Intell Rev, vol. 57, no. 10, Oct. 2024, doi: 10.1007/s10462-024-10884-2.
Y. Yang, H. A. Khorshidi, and U. Aickelin, “A review on over-sampling techniques in classification of multi-class imbalanced datasets: insights for medical problems,” 2024, Frontiers Media SA. doi: 10.3389/fdgth.2024.1430245.
X. Chen, T. Wang, J. Zhou, Z. Song, X. Gao, and X. Zhang, “Evaluating and mitigating bias in AI-based medical text generation,” Nat Comput Sci, vol. 5, pp. 388–396, Apr. 2025, doi: 10.1038/s43588-025-00789-7.
A. Das et al., “CGMacros: a pilot scientific dataset for personalized nutrition and diet monitoring,” Scientific Data , vol. 12, no. 1, Dec. 2025, doi: 10.1038/s41597-025-05851-7.
A. L. Goldberger et al., “PhysioBank, PhysioToolkit, and PhysioNet,” Circulation, vol. 101, no. 23, Jun. 2000, doi: 10.1161/01.CIR.101.23.e215.
D. N. Jawza, M. I. Mazdadi, A. Farmadi, T. H. Saragih, D. Kartini, and V. Abdullayev, “Enhancing Diabetes Prediction Accuracy Using Random Forest and XGBoost with PSO and GA-Based Feature Selection,” Journal of Electronics, Electromedical Engineering, and Medical Informatics, vol. 7, no. 2, pp. 295–306, Feb. 2025, doi: 10.35882/jeeemi.v7i2.626.
V. B. Liu, L. Y. Sue, O. M. Padilla, and Y. Wu, “Optimizing blood glucose predictions in type 1 diabetes patients using a stacking ensemble approach,” Endocrine and Metabolic Science, vol. 18, Jun. 2025, doi: 10.1016/j.endmts.2025.100253.
S. Dhanka and S. Maini, “Random Forest for Heart Disease Detection: A Classification Approach,” in 2021 IEEE 2nd International Conference On Electrical Power and Energy Systems (ICEPES), IEEE, Dec. 2021, pp. 1–3. doi: 10.1109/ICEPES52894.2021.9699506.
M. Maydanchi et al., “A Comparative Analysis of the Machine Learning Methods for Predicting Diabetes,” Journal of Operations Intelligence, vol. 2, no. 1, pp. 230–251, May 2024, doi: 10.31181/jopi21202421.
M. Pal and S. Parija, “Prediction of Heart Diseases using Random Forest,” J Phys Conf Ser, vol. 1817, p. 012009, Mar. 2021, doi: 10.1088/1742-6596/1817/1/012009.
A. Masbakhah, U. Sa’adah, and M. Muslikh, “Heart Disease Classification Using Random Forest and Fox Algorithm as Hyperparameter Tuning,” Journal of Electronics, Electromedical Engineering, and Medical Informatics, vol. 7, no. 4, pp. 964–976, Oct. 2025, doi: 10.35882/jeeemi.v7i4.932.
A. Nurul Puteri and A. Sumardin, “Comparison of Random Forest and XGBoost for Diabetes Classification with SHAP and LIME Interpretation,” Jurnal Teknologi Rekayasa), vol. 9, no. 2, 2024, doi: 10.31544/jtera.v9.i1.2024.121-130.
Z. Rafie, M. S. Talab, B. E. Z. Koor, A. Garavand, C. Salehnasab, and M. Ghaderzadeh, “Leveraging XGBoost and explainable AI for accurate prediction of type 2 diabetes,” BMC Public Health, vol. 25, no. 1, p. 3688, Dec. 2025, doi: 10.1186/s12889-025-24953-w.
S. Jaiswal and P. Gupta, Ensemble Approach: XGBoost, CATBoost, and LightGBM for Diabetes Mellitus Risk Prediction. 2022. doi: 10.1109/ICCSEA54677.2022.9936130.
H. Yang, Z. Liu, Y. Li, H. Wei, and N. Huang, “CatBoost–Bayesian Hybrid Model Adaptively Coupled with Modified Theoretical Equations for Estimating the Undrained Shear Strength of Clay,” Applied Sciences (Switzerland), vol. 13, no. 9, May 2023, doi: 10.3390/app13095418.
M. Hamid, F. Hajjej, A. S. Alluhaidan, and N. W. bin Mannie, “Fine tuned CatBoost machine learning approach for early detection of cardiovascular disease through predictive modeling,” Sci Rep, vol. 15, no. 1, Dec. 2025, doi: 10.1038/s41598-025-13790-x.
S. Bates, T. Hastie, and R. Tibshirani, “Cross-Validation: What Does It Estimate and How Well Does It Do It?,” J Am Stat Assoc, vol. 119, no. 546, pp. 1434–1445, Apr. 2024, doi: 10.1080/01621459.2023.2197686.
S. L. Cichosz, S. S. Olesen, and M. H. Jensen, “Explainable Machine-Learning Models to Predict Weekly Risk of Hyperglycemia, Hypoglycemia, and Glycemic Variability in Patients With Type 1 Diabetes Based on Continuous Glucose Monitoring,” J Diabetes Sci Technol, 2024, doi: 10.1177/19322968241286907.
V. B. Berikov, O. A. Kutnenko, J. F. Semenova, and V. V. Klimontov, “Machine Learning Models for Nocturnal Hypoglycemia Prediction in Hospitalized Patients with Type 1 Diabetes,” J Pers Med, vol. 12, no. 8, Aug. 2022, doi: 10.3390/jpm12081262.
H. Nemat, H. Khadem, J. Elliott, and M. Benaissa, “Data-driven blood glucose level prediction in type 1 diabetes: a comprehensive comparative analysis,” Sci Rep, vol. 14, no. 1, Dec. 2024, doi: 10.1038/s41598-024-70277-x.
W. Seo, Y. Bin Lee, S. Lee, S. M. Jin, and S. M. Park, “A machine-learning approach to predict postprandial hypoglycemia,” BMC Med Inform Decis Mak, vol. 19, no. 1, Nov. 2019, doi: 10.1186/s12911-019-0943-4.
R. Cui, C. J. Nolan, E. Daskalaki, and H. Suominen, “Jointly Predicting Postprandial Hypoglycemia and Hyperglycemia Using Continuous Glucose Monitoring Data in Type 1 Diabetes,” in 2023 45th Annual International Conference of the IEEE Engineering in Medicine & Biology Society (EMBC), IEEE, Jul. 2023, pp. 1–7. doi: 10.1109/EMBC40787.2023.10340094.
A. Mamun et al., “LLM-Powered Prediction of Hyperglycemia and Discovery of Behavioral Treatment Pathways from Wearables and Diet,” Sensors, vol. 25, no. 17, Sep. 2025, doi: 10.3390/s25175372.
N. K. Choudhry, S. Priyadarshini, J. Swamy, and M. Mehta, “Use of Machine Learning to Predict Individual Postprandial Glycemic Responses to Food Among Individuals With Type 2 Diabetes in India: Protocol for a Prospective Cohort Study,” JMIR Res Protoc, vol. 14, 2025, doi: 10.2196/59308.
Copyright (c) 2026 Muhammad Rafly Alfarizqy Maulana, Fatma Indriani, Friska Abadi, Dwi Kartini, Muhammad Itqan Mazdadi

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Authors who publish with this journal agree to the following terms:
- Authors retain copyright and grant the journal right of first publication with the work simultaneously licensed under a Creative Commons Attribution-ShareAlikel 4.0 International (CC BY-SA 4.0) that allows others to share the work with an acknowledgement of the work's authorship and initial publication in this journal.
- Authors are able to enter into separate, additional contractual arrangements for the non-exclusive distribution of the journal's published version of the work (e.g., post it to an institutional repository or publish it in a book), with an acknowledgement of its initial publication in this journal.
- Authors are permitted and encouraged to post their work online (e.g., in institutional repositories or on their website) prior to and during the submission process, as it can lead to productive exchanges, as well as earlier and greater citation of published work (See The Effect of Open Access).


.png)
.png)
.png)
.png)
.png)