AccScience Publishing / AIH / Online First / DOI: 10.36922/AIH026030003
ORIGINAL RESEARCH ARTICLE

A clinically weighted loss function for risk-sensitive blood glucose forecasting

Joseph Passant1* Andrea Corradini1*
Show Less
1 Department of Computer Science, School of Computer Science and Informatics, University of Liverpool, Liverpool, United Kingdom
2 Department of Digital Business & Software Engineering, Management Center Innsbruck, Innsbruck, Austria
Received: 12 January 2026 | Revised: 12 February 2026 | Accepted: 25 February 2026 | Published online: 26 May 2026
© 2026 by the Author(s). This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution 4.0 International License ( https://creativecommons.org/licenses/by/4.0/ )
Abstract

Blood glucose forecasting models have the potential to improve glycemic control and reduce the burden of diabetes management. However, most prior work has focused on optimizing statistical accuracy, which does not necessarily align with clinical safety and efficacy. This study introduces a clinically weighted root mean squared error (CW-RMSE) loss function that incorporates clinical risk into model optimization by weighting prediction errors according to continuous glucose error grid analysis (CG-EGA) classification and glycemic range to reduce clinically harmful errors. WinFormer, an Informer-based prediction model employing windowed attention, was trained using the REPLACE-BG dataset and either root mean squared error (RMSE) or CW-RMSE loss functions to predict blood glucose values over a 120-min prediction horizon. Compared to RMSE loss, CW-RMSE loss produced significant improvements in CG-EGA classification in hypoglycemia (accurate predictions: 83.2% to 88.0%; erroneous predictions: 13.2% to 8.1%) while maintaining performance for predictions of values in euglycemic (accurate predictions: 92.6% to 92.4%; erroneous predictions: 2.7% to 2.4%) and hyperglycemic ranges (accurate predictions: 91.2% to 90.6%; erroneous predictions: 4.1% to 4.1%). In comparison to RMSE loss, CW-RMSE loss also led to significant improvements in RMSE and mean absolute error (MAE) in hypoglycemia (RMSE: 39.8 mg/dL to 29.8 mg/dL; MAE: 26.6 mg/dL to 16.4 mg/dL), but worse RMSE and MAE in the euglycemia range (RMSE: 31.8 mg/dL to 33.8 mg/dL; MAE: 23.1 mg/dL to 25.1 mg/dL) and the hyperglycemia range (RMSE: 44.9 mg/dL to 52.3 mg/dL; MAE: 30.0 mg/dL to 34.8 mg/dL). These findings demonstrate that cost-sensitive learning can effectively guide blood glucose forecasting models toward more clinically meaningful and risk-aware optimization.

Graphical abstract
Keywords
Blood glucose forecasting
Machine learning
Cost-sensitive learning
Type 1 diabetes
Funding
None.
Conflict of interest
The authors declare they have no competing interests.
References
  1. Lucier J, Mathias PM. Type 1 diabetes. In: StatPearls. Treasure Island, FL: StatPearls Publishing; 2024. Last accessed on February 11, 2026. https://www.ncbi.nlm.nih.gov/books/NBK507713/
  2. Battelino T, Danne T, Bergenstal RM, et al. Clinical targets for continuous glucose monitoring data interpretation: recommendations from the international consensus on time in range. Diabetes Care. 2019;42(8):1593-1603. doi: 10.2337/dci19-0028
  3. Hankosky ER, Schapiro D, Gunn KB, Lubelczyk EB, Mitroi J, Nelson DR. Gaps remain for achieving HbA1c targets for people with type 1 or type 2 diabetes using insulin: results from NHANES 2009–2020. Diabetes Ther. 2023;14(6):967- 975. doi: 10.1007/s13300-023-01399-0
  4. Duinkerken E, Snoek FJ, de Wit M. The cognitive and psychological effects of living with type 1 diabetes: a narrative review. Diabet Med. 2020;37(4):555-563. doi: 10.1111/dme.14216
  5. Bollepalli S, Smith LB, Vasquez A, Rodriguez H, Vehik K. Addressing the burdens of type 1 diabetes in youth. Clin Pract. 2012;9(4):409-424. doi: 10.2217/cpr.12.33
  6. Joensen LE, Almdal TP, Willaing I. Associations between patient characteristics, social relations, diabetes management, quality of life, glycaemic control and emotional burden in type 1 diabetes. Prim Care Diabetes. 2016;10(1):41-50. doi: 10.1016/j.pcd.2015.06.007
  7. Lin R, Brown F, James S, Jones J, Ekinci E. Continuous glucose monitoring: a review of the evidence in type 1 and type 2 diabetes mellitus. Diabet Med. 2021;38(5):e14528. doi: 10.1111/dme.14528
  8. DiMeglio LA, Evans-Molina C, Oram RA. Type 1 diabetes. Lancet. 2018;391(10138):2449-2462. doi: 10.1016/S0140-6736(18)31320-5
  9. Ehrmann DE, Laviola L, Priesterroth LS, Hermanns N, Babion N, Glatzer T. Fear of hypoglycaemia and diabetes distress: expected reduction by glucose prediction. J Diabetes Sci Technol. 2024;18(5):1027-1034. doi: 10.1177/19322968241267886
  10. Liu K, Li L, Ma Y, et al. Machine learning models for blood glucose level predictions in patients with diabetes mellitus: systematic review and network meta-analysis. JMIR Med Inform. 2023;11(1):e47833. doi: 10.2196/47833
  11. Langarica S, de la Vega D, Cariman N, et al. Deep learning–based glucose prediction models: a guide for practitioners and a curated dataset for improved diabetes management. IEEE Open J Eng Med Biol. 2024;5(5):467-475. doi: 10.1109/OJEMB.2024.3365290
  12. Vaswani A, Shazeer N, Parmar N, et al. Attention is all you need. arXiv. Preprint posted June 12, 2017. doi: 10.48550/arXiv.1706.03762
  13. Zhou H, Zhang S, Peng J, et al. Informer: beyond efficient transformer for long sequence time-series forecasting. AAAI. 2021;35(12):11106-11115. doi: 10.1609/aaai.v35i12.17325
  14. Zhou H. Informer2020 [software]. GitHub. Published 2020. Last accessed on February 11, 2026. https://github.com/ zhouhaoyi/Informer2020
  15. Sergazinov R, Armandpour M, Gaynanova I. Gluformer: transformer-based personalized glucose forecasting with uncertainty quantification. In: Proceedings of the ICASSP 2023 - 2023 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP); June 4-10, 2023; Rhodes Island, Greece. IEEE; 2023:1-5. doi: 10.1109/icassp49357.2023.10096419
  16. Zhu T, Chen T, Kuang L, Zeng J, Li K, Georgiou P. Edge-based temporal fusion transformer for multi-horizon blood glucose prediction. In: Proceedings of the IEEE International Symposium on Circuits and Systems (ISCAS); May 21–25, 2023; Monterey, CA. IEEE; 2023. doi: 10.1109/ISCAS46773.2023.10181448
  17. Cheng M, Diao X, Cui Y, Liu W, Cheng S. Toward short-term glucose prediction solely based on CGM time series. arXiv. Preprint posted April 18, 2024. doi: 10.48550/arXiv.2404.11924
  18. Zhu T, Afentakis I, Li K, et al. Multi-Horizon Glucose Prediction Across Populations With Deep Domain Generalization. IEEE J Biomed Health Inform. 2025;29(8):5424-5437. doi: 10.1109/jbhi.2024.3428921
  19. Xue Y, Guan S, Jia W. BGformer: an improved Informer model to enhance blood glucose prediction. J Biomed Inform. 2024;157(1):104715. doi: 10.1016/j.jbi.2024.104715
  20. de Bois M, El Yacoubi MA, Ammi M. GLYFE: review and benchmark of personalised glucose predictive models in type 1 diabetes. Med Biol Eng Comput. 2021;60(1):1-17. doi: 10.1007/s11517-021-02437-4
  21. Clarke W, Cox D, Gonder-Frederick LA, Carter W, Pohl SL. Evaluating clinical accuracy of systems for self-monitoring of blood glucose. Diabetes Care. 1987;10(5):622-628. doi: 10.2337/diacare.10.5.622
  22. Kovatchev BP, Cox DJ, Gonder-Frederick LA, Clarke WL. Evaluating the accuracy of continuous glucose-monitoring sensors: continuous glucose-error grid analysis illustrated by TheraSense Freestyle Navigator data. Diabetes Care. 2004;27(8):1922-1928. doi: 10.2337/diacare.27.8.1922
  23. Devi D, Biswa SK, Purkayastha B. A review on solution to class imbalance problem: undersampling approaches. In: Proceedings of the International Conference on Computational Performance Evaluation (ComPE); July 2–4, 2020; Shillong, India. IEEE; 2020. doi: 10.1109/ComPE49325.2020.9200087
  24. Saripuddin M, Suliman A, Sameon SS, Jorgenson BN. Random undersampling on imbalanced time series data for anomaly detection. In: Proceedings of the 4th International Conference on Machine Learning and Machine Intelligence (MLMI 2021); September 17–19, 2021; Hangzhou, China. ACM; 2021:151-156. doi: 10.1145/3490725.3490748
  25. Araf I, Idri A, Chairi I. Cost-sensitive learning for imbalanced medical data: a review. Artif Intell Rev. 2024;57(4). doi: 10.1007/s10462-023-10652-8
  26. Aleppo G, Ruedy KJ, Riddlesworth TD, et al. REPLACE-BG: a randomized trial comparing continuous glucose monitoring with and without routine blood glucose monitoring in adults with well-controlled type 1 diabetes. Diabetes Care. 2017;40(4):538-545. doi: 10.2337/dc16-2482
  27. Jaeb Center for Health Research. REPLACE-BG public dataset [data set]. 2017. Last accessed on February 11, 2026. https://public.jaeb.org/dataset/546
  28. Passant J. Informer-based blood glucose prediction: a comparative analysis of attention mechanisms and training methods. Master’S dissertation. Liverpool, UK: University of Liverpool; 2024. Last accessed on May 22, 2026. https://github.com/JosephPassant/Blood-Glucose-Prediction/blob/ /report/passant_ibgp.pdf
  29. de Bois M. CG-EGA [software]. GitHub. Published 2020. Last accessed on February 11, 2026. https://github.com/dotXem/CG-EGA
  30. Ahmed B, Ali ME, Masud MM, Nazni M. Recent trends and techniques of blood glucose level prediction for diabetes control. Smart Health. 2024;32:100457. doi: 10.1016/j.smhl.2024.100457
  31. Katsarou DN, Georga EI, Christou MA, et al. Optimizing hypoglycaemia prediction in type 1 diabetes with ensemble machine learning modeling. BMC Med Inform Decis Mak. 2025;25(1):46. doi: 10.1186/s12911-025-02867-2
  32. Alshehri OS, Alshehri OM, Samma H. Blood glucose prediction using RNN, LSTM and GRU: a comparative study. In: Proceedings of the IEEE International Conference on Advanced Systems and Emergent Technologies (IC_ASET); April 27–29, 2024; Hammamet, Tunisia. IEEE; 2024. doi: 10.1109/IC_ASET61847.2024.10596176
  33. Annuzzi G, Arpaia P, Bozzetto L, Criscuolo S, Giugliano S, Pesola M. Assessing the features on blood glucose level prediction in type 1 diabetes patients through explainable artificial intelligence. In: Proceedings of the IEEE International Conference on Metrology for Extended Reality, Artificial Intelligence and Neural Engineering (MetroXRAINE); October 25–27, 2023; Milan, Italy. IEEE; 2023. doi: 10.1109/MetroXRAINE58569.2023.10405831
  34. Butunoi BP, Stolojescu-Crisan C, Negru V. Short-term glucose prediction in type 1 diabetes. Procedia Comput Sci. 2024;238(10):41-48. doi: 10.1016/j.procs.2024.05.194
  35. Nordin MSM, Mahmud F. Univariate and multivariate time series blood glucose prediction with LSTM deep learning model. Evol Electr Electron Eng. 2024;5(1):276-285. Last accessed on February 11, 2026. https://publisher.uthm.edu. my/periodicals/index.php/eeee/article/view/15439. doi: 10.30880/eeee.2024.05.01.035
  36. Rehman NU, Contreras I, Benyeto A, Vehi J. The impact of missing continuous blood glucose samples on machine learning models for predicting postprandial hypoglycaemia: an experimental analysis. Mathematics. 2024;12(10):1567. doi: 10.3390/math12101567
  37. Mohamed Youssuff AR, Zainulabedin Hasan M, Anand R, Rajasekhara Babu M. Leveraging deep learning models for continuous glucose monitoring and prediction in diabetes management: toward enhanced blood sugar control. J Syst Assur Eng Manag. 2024;15(6):2077-2084. doi: 10.1007/s13198-023-02200-y
  38. Stawarz K, Katz D, Ayobi A, et al. Co-designing opportunities for human-centred machine learning in supporting type 1 diabetes decision making. Int J Hum Comput Stud. 2023;173:103003. doi: 10.1016/j.ijhcs.2023.103003
  39. Barth CM, Bernard J, Huang EM. “It’s like a glimpse into the future”: exploring the role of blood glucose prediction technologies for type 1 diabetes self-management. In: Proceedings of the 2024 CHI Conference on Human Factors in Computing Systems (CHI ’24); May 11–16, 2024; Honolulu, HI. ACM; 2024:1-21. doi: 10.1145/3613904.3642234
Share
Back to top
Artificial Intelligence in Health, Electronic ISSN: 3029-2387 Print ISSN: 3041-0894, Published by AccScience Publishing