![[images 1.jpeg|411]]
Diabetes is a progressive metabolic disease that often develops gradually through a pre-diabetes stage before progressing to Type 2 Diabetes. Early identification of high-risk individuals provides an opportunity for lifestyle intervention before irreversible complications occur.
In this project, I built a multiclass machine learning model to predict **Diabetes Stage** using demographic information, lifestyle habits, family history, and clinical measurements.
Target variable:
- No Diabetes
- Pre-Diabetes
- Type 2 Diabetes
(Type 1 and Gestational Diabetes were excluded because they have different clinical mechanisms.)
# Project Workflow
## Model Development
Compared multiple machine learning models.
Models evaluated:
- Logistic Regression
- Random Forest
- XGBoost
- LightGBM
- CatBoost
Evaluation metrics:
- Accuracy
- Macro F1
- Weighted F1
- ROC-AUC
CatBoost consistently achieved the best overall performance.
## Hyperparameter Tuning
Optimized CatBoost using RandomizedSearchCV.
Parameters tuned included:
- iterations
- depth
- learning_rate
- l2_leaf_reg
- random_strength
- bagging_temperature
- border_count
The tuned model produced the highest Macro F1 score while maintaining strong discrimination across all diabetes stages.
## Model Interpretation
Instead of treating the model as a black box, I applied SHAP (SHapley Additive exPlanations) to understand:
- Global feature importance
- Feature importance by diabetes stage
- SHAP dependence plots
- Disease progression from Pre-Diabetes to Type 2 Diabetes
# Key Findings
## 1. Family history is the strongest predictor
Family history of diabetes was the most influential feature for predicting Type 2 Diabetes.
The SHAP dependence plot shows a dramatic increase in prediction of positive Type 2 diabetes once a patient has a positive family history. Although genetics cannot be modified, individuals with a family history should receive **earlier screening and preventive care**.
![[Screenshot 2026-09-02 at 11.09.25 AM.png|269]]
## 2. Age substantially increases diabetes risk
Age is the second most important predictor and shows an almost perfectly monotonic relationship. The model suggests:
- Younger adults have substantially lower risk.
- Risk increases steadily through middle age.
- The largest increase occurs between approximately **45–60 years**.
- Risk begins to plateau among older adults.
![[Screenshot 2026-09-02 at 11.10.35 AM.png|278]]
## 3. Physical activity strongly reduces diabetes risk
Physical activity is another strong predictor and shows one of the clearest nonlinear relationships. The SHAP plot suggests:
- Sedentary individuals have much higher predicted risk.
- Risk decreases rapidly as weekly activity increases.
- The greatest improvement occurs between approximately **150–300 minutes of exercise per week**.
- Beyond this point, additional activity provides diminishing returns.
![[Screenshot 2026-09-02 at 11.11.45 AM.png|291]]
## 4. BMI increases risk almost linearly
BMI ranks as moderate predictor. Unlike physical activity, BMI shows an approximately linear relationship. Higher BMI consistently increases predicted diabetes risk with no obvious saturation.
![[Screenshot 2026-09-02 at 11.13.43 AM.png|305]]
## 5. Healthy diet lowers diabetes risk
Diet score demonstrates an moderate and almost perfectly monotonic inverse relationship. Higher diet quality consistently lowers predicted diabetes risk. Unlike many medical variables, there is no abrupt threshold, suggesting **gradual improvements** in diet continue providing benefits.
![[Screenshot 2026-09-02 at 11.16.07 AM.png|314]]
## 6. Higher HDL cholesterol is protective
HDL cholesterol exhibits a moderate and nonlinear inverse relationship. Patients with low HDL cholesterol have substantially higher predicted diabetes risk. Once HDL reaches healthier levels, the protective effect begins to plateau.
![[Screenshot 2026-09-02 at 11.16.59 AM.png|322]]
# Disease Progression Analysis
To better understand disease progression, I compared SHAP feature importance between **Pre-Diabetes** and **Type 2 Diabetes**.
## Features that become substantially more important
| Feature | Interpretation |
| ----------------- | ------------------------------------------- |
| Family history | Strongest differentiator |
| Age | Importance increases substantially |
| Physical activity | Lifestyle becomes increasingly influential |
| BMI | Obesity contributes more strongly |
| Diet quality | Poor diet increasingly predicts progression |
| HDL cholesterol | Lipid metabolism becomes more important |
These results suggest that progression from Pre-Diabetes to Type 2 Diabetes is influenced by both genetic predisposition and long-term lifestyle behaviors.
# Recommendations
## 1. Prioritize screening for high-risk individuals
Patients with:
- Family history of diabetes
- Older age
- Higher BMI
should receive earlier metabolic screening.
## 2. Promote regular physical activity
The largest reduction in predicted diabetes risk occurs when sedentary individuals increase activity to approximately **150–300 minutes per week**. Encouraging inactive patients to reach recommended activity levels may produce substantial benefits.
## 3. Improve dietary quality
The model suggests diabetes risk decreases consistently as diet quality improves. Lifestyle coaching and nutrition education remain important preventive strategies.
## 4. Focus on weight management
BMI remains one of the modifiable predictors. Programs targeting healthy weight maintenance may reduce progression from Pre-Diabetes to Type 2 Diabetes.
## 5. Monitor lipid health
Patients with low HDL cholesterol and elevated triglycerides appear to have higher predicted diabetes risk. Regular lipid monitoring may help identify patients who would benefit from earlier intervention.
# Model Performance and Limitations
Overall, the model demonstrates **moderate predictive performance** with 0.412 macro F1, indicating that diabetes stage cannot be fully explained by the available features alone.
Several factors may contribute to this limitation:
- **Missing predictive variables.** Although the dataset includes demographics, lifestyle habits, and several clinical measurements, important information such as longitudinal health records, medication history, genetic factors, and additional laboratory biomarkers may not be available. These factors likely influence disease progression beyond what the current model can capture.
- **Substantial overlap between disease stages.** Pre-Diabetes and early Type 2 Diabetes often share very similar characteristics, making them inherently difficult to distinguish. Patients with comparable BMI, physical activity, blood pressure, and cholesterol levels may belong to different diabetes stages.
- **Multiclass classification is inherently challenging.** Predicting three clinically related stages (No Diabetes, Pre-Diabetes, and Type 2 Diabetes) is considerably more difficult than a binary classification problem. Most prediction errors are expected to occur between adjacent disease stages rather than between healthy individuals and patients with established diabetes.
Despite these limitations, the SHAP analysis demonstrates that the model successfully identifies clinically meaningful risk factors, including family history, age, physical activity, BMI, diet quality, HDL cholesterol, and triglycerides. These findings suggest that the model captures realistic biological patterns while also highlighting that diabetes progression depends on additional factors not represented in the dataset.