Abstract:Objective To explore a method for extracting features of blood glucose fluctuations in patients with type 2 diabetes mellitus (T2DM) based on continuous glucose monitoring (CGM) data, and to construct a hypoglycemia/hyperglycemia early warning model. Methods From October 2024 to October 2025, a total of 246 patients with T2DM were screened in the Department of Endocrinology of Hopeshine-Minsheng Hospital of Xinzheng, and 98 of them were included. All patients wore the CGM system for a duration of at least 14 days, and 12 fluctuation characteristics such as time in range (TIR) and mean amplitude of glycemic excursions (MAGE) were extracted. The extreme gradient boosting (XGBoost) algorithm was used to construct early warning models for hypoglycemia (<3.9 mmol/L) and hyperglycemia (>13.9 mmol/L) within the next 4 h, and the training set and the validation set were divided in a 7 vs. 3 ratio. Furthermore, model performance was evaluated by area under the curve (AUC), and feature contribution analysis was performed using Shapley additive explanation (SHAP). Results The mean age of patients was (58.6±9.2) years, glycated hemoglobin A1c (HbA1c) was (8.4±1.6)%, MAGE was (4.8±1.7) mmol/L, and TIR was (67.2±18.4)%. The AUC of the hypoglycemia early warning model validation set was 0.91 (95%CI: 0.86?0.95), the sensitivity was 86.7%, and the specificity was 88.4%. The AUC of the hyperglycemia early warning model was 0.89 (95%CI: 0.84?0.93), the sensitivity was 84.2%, and the specificity was 87.1%. The SHAP analysis showed that nocturnal MAGE, the most recent 2-hour blood glucose slope, and the proportion of time below range (TBR) were the core contributing features of hypoglycemia. Meanwhile, the peak 2-h postprandial blood glucose and the proportion of time above range (TAR) were characteristics of the core contribution of fasting C-peptide (FCP) to hyperglycemia. Conclusion Based on the multi-dimensional fluctuation characteristics of CGM combined with XGBoost algorithm, a high-precision early warning of hypoglycemia and hyperglycemia in T2DM patients can be achieved, and the model has good interpretability.