Predicting and classifying type 2 diabetes using a transparent ensemble model combining random forest, k-nearest neighbor, and neural networks

利用结合随机森林、k近邻和神经网络的透明集成模型预测和分类2型糖尿病

阅读:1

Abstract

Diabetes is one of the major health challenges in today's world, since chronic elevation of blood sugar can cause serious and sometimes irreparable damage to organs such as the heart, kidneys, and nervous system. Early detection of this disease plays a vital role in reducing its complications. However, machine learning and deep learning models often face distrust in medical settings due to their opaque, "black-box" nature. The aim of this study was to combine three machine learning algorithms using stacking and voting methods to propose a model for type 2 diabetes detection, and to increase transparency by using the explainability techniques LIME and SHAP to identify important features. This study used medical data from 768 Pima Indians Diabetes samples, including 8 features such as age, BMI, glucose, insulin, blood pressure, skin thickness, pregnancies, and family history. Data preprocessing included mean imputation for missing or zero values, Min-Max normalization, and classification into "Normal", "Prediabetes", and "Diabetes" based on fasting glucose thresholds. Feature selection was performed using Spearman correlation to retain the most relevant variables. A hybrid machine learning model was developed using three base models Neural Network (NN), k-Nearest Neighbors (KNN), and Random Forest (RF) with automated hyperparameter tuning. The outputs of these models were combined via stacking using a logistic regression (LR) meta-model and in parallel using a soft voting method. Nested cross-validation (5 outer and 5 inner folds) was applied to prevent data leakage and ensure robust evaluation. Model interpretability was assessed using LIME for local explanations and SHAP for global feature importance. Decision thresholds and influential feature regions were identified, and model calibration and decision curves evaluated clinical reliability. Models performance was evaluated using accuracy, precision, recall, specificity, F1-score, AUROC, Brier Score (1-B), and Expected Calibration Error (1-E). Statistical reliability was assessed using bootstrap resampling to compute 95% confidence intervals, as well as paired tests to compare the hybrid model with the base models and voting ensemble. Based on the evaluation metrics, the stacking ensemble achieved perfect performance for Class 0, with 100% accuracy, precision, recall, specificity, F1 score, and AUROC, alongside the highest calibration metrics (Brier Score: 99.9, ECE: 98.7). The Random Forest model also excelled, achieving 100% accuracy, precision, recall, specificity, and F1 score for Class 0 and Class 2. In contrast, the KNN model consistently underperformed, particularly for Class 0 (F1: 83.3, Precision: 83.3, Recall: 83.3). The Neural Network demonstrated strong recall for Class 0 (100%), while the voting ensemble showed balanced results but was slightly outperformed by the top ensemble methods. Explainable AI analyses using LIME and SHAP revealed that glucose was the most influential predictor for identifying the Pre-diabetes state. Both methods consistently identified a decision band between 0.35 and 0.47 (corresponding to 100-125 mg/dL) as the transition zone between "Normal" and "Prediabetes", confirming the model's alignment with WHO/ADA diagnostic criteria. The stacking model achieved perfect performance and superior calibration, outperforming all other models in type 2 diabetes prediction and classification. Explainability techniques (LIME and SHAP) identified glucose level, body mass index, and blood pressure as key predictive factors. This approach provides an accurate and interpretable tool for clinical decision support in healthcare systems.

特别声明

1、本页面内容包含部分的内容是基于公开信息的合理引用;引用内容仅为补充信息,不代表本站立场。

2、若认为本页面引用内容涉及侵权,请及时与本站联系,我们将第一时间处理。

3、其他媒体/个人如需使用本页面原创内容,需注明“来源:[生知库]”并获得授权;使用引用内容的,需自行联系原作者获得许可。

4、投稿及合作请联系:info@biocloudy.com。