Machine Learning–Based Risk Stratification for Incident Cancer in Patients With Type 2 Diabetes: An Electronic Health Record Cohort Study (Preprint)
Abstract
BACKGROUND Type 2 diabetes mellitus (T2DM) is a major global health concern, affecting over 537 million adults worldwide in 2021, with projections reaching 783 million by 2045. Cancer represents a significant comorbidity in T2DM patients, accounting for an increasing proportion of hospital admissions and mortality. The complex interplay between T2DM and cancer involves shared risk factors including obesity, physical inactivity, chronic inflammation, and metabolic dysregulation. Early identification of cancer risk in T2DM patients could enable targeted preventive interventions and improve clinical outcomes. OBJECTIVE This study aimed to develop and validate machine learning models for predicting breast cancer and lung cancer risk in patients with type 2 diabetes using routinely collected clinical and biochemical parameters from electronic health records. METHODS This retrospective cohort study analyzed electronic health record data from the National Taiwan University Hospital Integrated Medical Database (NTUH-iMD), which stores patient-level information continuously from NTUH and its affiliated branches serving citizens throughout Taiwan. The study included 68,000 adult T2DM patients (≥20 years) from March 2007 to December 2019. Patients were identified using ICD-10 diagnostic codes for T2DM (E11) and cancer (C33-C34 for lung cancer, C50 for breast cancer). We collected demographic data and biochemical parameters including lipid profiles, inflammatory markers, renal function tests, liver enzymes, and glycemic control indicators. Three machine learning algorithms were implemented: eXtreme Gradient Boosting (XGBoost), Light Gradient Boosting Machine (LightGBM), and Random Forest. Data preprocessing included regression-based imputation for missing values, Min-Max normalization, and k-fold cross-validation. Model performance was evaluated using accuracy, sensitivity, specificity, and area under the receiver operating characteristic curve (AUC-ROC). Binary logistic regression analysis identified significant risk factors with odds ratios and 95% confidence intervals. This study was approved by the Research Ethics Committee of National Taiwan University Hospital (IRB No. 202110098RINA). RESULTS Among 68,000 T2DM patients, 1,714 developed breast cancer and 1,970 developed lung cancer during the study period. Student's t-tests revealed significant differences (p3.5 g/dL (OR=5.131), and TG >150 mg/dL (OR=1.352). For lung cancer prediction, significant factors included BMI, albumin (Alb), globulin (Glo), blood urea nitrogen (BUN), total cholesterol (T-CHO), hsCRP, platelet count (PLT), hemoglobin A1c (HbA1c), and fasting glucose (GLUAC). Notably, hsCRP >1 mg/dL demonstrated the strongest association (OR=2.044), while high platelet count >378×10³/µL showed an OR of 1.323. The machine learning models demonstrated robust predictive performance across both cancer types, with the best-performing model achieving an AUC-ROC of 0.786 in internal validation and 0.764 in external validation for lung cancer prediction. CONCLUSIONS This study successfully developed machine learning-based prediction models for breast cancer and lung cancer risk in T2DM patients using routinely available clinical data from electronic health records. The identification of specific biochemical markers as significant predictors provides clinically actionable insights for early cancer detection and prevention strategies in this high-risk population. The models demonstrated good discriminative ability and could be integrated into clinical decision support systems to facilitate timely interventions. Future research should focus on external validation in diverse populations, prospective validation studies, and integration with additional data modalities including genetic and lifestyle factors to further enhance prediction accuracy and clinical utility. CLINICALTRIAL no
Fields of Study & Subjects
Machine Learning in Healthcare
Artificial Intelligence in Healthcare
Metabolism
Diabetes
and Cancer
Publication details
- Publication date
- 22 February 2026
- Language
- EN
- Document type
- Preprint