All projects

Predicting hospital readmission for diabetic patients

Can routine hospital data tell which diabetic patients will be back within 30 days?

Summary

The model cannot decide on its own who will be readmitted, but it can rank patients by risk. Following up the riskiest 20% of patients would catch a third of all readmissions, about 1.7 times more than picking patients at random.

Year
2025
Duration
2 months
Tools
Python, scikit-learn, XGBoost, imbalanced-learn, pandas
Patient journey: admission, hospital stay, discharge with a risk check, then a 30-day window in which a readmission may happen.

The model is meant to be used at discharge, to decide which patients need a follow-up in the next 30 days.

Key results

The problem

About 1 in 11 diabetic patients in this dataset (101,766 hospital stays from 130 US hospitals) is readmitted within 30 days. Readmissions are costly and often preventable, but deciding who needs extra follow-up depends on each doctor. We framed it as a binary classification task: readmitted within 30 days or not. Recall mattered most, because missing a high-risk patient is worse than an extra follow-up call.

What we did

  1. Cleaned the data from 101,766 stays to 67,569 patients: kept only each patient’s first stay (so the same person never appears in both training and test data) and removed patients who died, since they cannot be readmitted.
  2. Grouped 691 ICD-9 diagnosis codes into a handful of medical categories (circulatory, respiratory, diabetes, injury and others).
  3. Compared 8 models with stratified 5-fold cross-validation, undersampling the majority class to handle the imbalance.
  4. Ran three rounds of feature engineering and selection (for example combining visit counts into one feature, removing rarely used medications).
  5. Tuned gradient boosting, random forest and XGBoost with grid search.
  6. Afterwards, I re-ran the final model and evaluated it the way a hospital would use it: ranking patients by predicted risk.

Results

At the default threshold, the gradient boosting model reaches a recall of 0.55 and a precision of 0.13 on 13,514 test patients. A precision of 0.13 sounds low, but only 9.1% of patients are readmitted, so the patients the model flags are readmitted 1.4 times as often as average (12.9% vs 9.1%).

The model is more useful as a ranking. Following up the 10% of patients with the highest predicted risk catches 18% of all readmissions; the top 20% catches 33%, the top 30% catches 45% and the top 50% catches 65%.

Line chart: share of all readmissions caught against share of patients followed up, ordered from highest to lowest predicted risk. The model's curve lies above the dashed diagonal for random selection, reaching 33% at 20% of patients.
Share of all readmissions caught when following up patients from highest to lowest predicted risk. The dashed line is random selection.
Patients followed up Readmissions caught
Top 10% 18%
Top 20% 33%
Top 30% 45%
Top 50% 65%

What I learned