View the fully rendered Jupyter Notebook
This project develops and evaluates an interpretable machine-learning workflow for predicting whether a patient with diabetes will be readmitted to a hospital within 30 days of discharge.
The analysis emphasizes careful validation, patient-level leakage prevention, probability calibration, and clinically interpretable model explanation rather than model complexity alone.
The project uses the Diabetes 130-US Hospitals for Years 1999–2008 dataset from the UCI Machine Learning Repository.
The original dataset contains:
- 101,766 hospital encounters
- 71,518 unique patients
- Clinical, utilization, diagnosis, medication, and discharge-related variables
- A three-category readmission outcome:
<30,>30, andNO
For this project, the target outcome was defined as:
1= readmitted within 30 days0= not readmitted within 30 days
The workflow includes:
- Data loading and initial audit
- Binary outcome construction
- Missing-value assessment
- Patient-level train–test splitting to prevent leakage
- Clinical eligibility filtering
- Diagnosis-code grouping
- Feature encoding and preprocessing
- Leakage-safe cross-validation
- Comparison of logistic regression, random forest, and gradient boosting
- Protected test-set evaluation
- Probability calibration
- Risk-threshold selection using development data only
- Permutation-based predictor importance
- Clinically interpretable risk summaries with confidence intervals
| Model | Cross-Validated ROC-AUC |
|---|---|
| Balanced logistic regression | 0.663 |
| Random forest | 0.670 |
| Gradient boosting | 0.673 |
Gradient boosting provided the strongest overall performance and was selected for final evaluation.
| Metric | Result |
|---|---|
| ROC-AUC | 0.671 |
| Average precision | 0.215 |
| No-skill average-precision benchmark | 0.109 |
| Calibrated Brier score | 0.093 |
| Calibrated log loss | 0.325 |
| Selected calibrated risk threshold | 0.125 |
| Sensitivity | 0.547 |
| Specificity | 0.696 |
| Balanced accuracy | 0.622 |
| Percentage flagged as higher risk | 33.03% |
The raw class-balanced gradient-boosting probabilities substantially overestimated absolute risk.
Sigmoid calibration improved probability accuracy:
| Measure | Raw probabilities | Calibrated probabilities |
|---|---|---|
| Mean predicted probability | 0.451 | 0.114 |
| Observed readmission rate | 0.109 | 0.109 |
| Brier score | 0.217 | 0.093 |
| Log loss | 0.623 | 0.325 |
Calibration improved probability interpretation without changing risk-ranking performance.
Prior inpatient utilization was the strongest predictor of 30-day readmission risk.
| Prior inpatient encounters | Observed readmission rate |
|---|---|
| 0 | 8.77% |
| 1 | 14.00% |
| 2 | 20.02% |
| 3 | 22.12% |
| 4 or more | 30.92% |
Discharge destination was the second strongest predictor. Encounters involving rehabilitation or continued institutional care showed higher observed readmission rates than routine discharge to home.
This project demonstrates an interpretable ML workflow for risk stratification.
The findings represent predictive associations, not causal effects. The model is a portfolio demonstration and should not be treated as a clinically validated decision tool.
- Python
- pandas
- NumPy
- matplotlib
- scikit-learn
- Google Colab
Diabetes_Readmission_Prediction_Project.ipynbreadmission_predictor_importance.pngreadmission_risk_by_prior_inpatient_utilization_with_ci.pngreadmission_risk_by_discharge_destination_with_ci.pngreadmission_precision_recall_curve.pngreadmission_roc_curve.pngreadmission_model_performance_summary.csvreadmission_model_key_findings.csv
This project supports the following professional positioning:
PhD Statistical Consultant | Advanced Quantitative Modeling (R, Mplus)
Supporting capability: interpretable machine learning and reproducible statistical computing in Python.
Professional website: https://drimransarmad.com




