Data DAT-06 · Jan 2025
Stroke risk prediction
Classification model that identifies patients at risk of stroke on a highly imbalanced medical dataset, followed by a critical review of our first version.

AThe question
From a few simple medical details (age, hypertension, glucose, BMI, smoking…), can we predict whether a patient is at risk of a stroke? The goal is to miss as few cases as possible.
BThe data
5,110 patients and 10 variables, of whom only 249 had a stroke (under 5%). Some BMI values are missing.
CThe method
Data exploration, then imputation, encoding and scaling combined in a scikit-learn pipeline. The imbalance is handled by class weighting or by SMOTE applied only to the training folds. We compared logistic regression, Random Forest and XGBoost by cross-validation on ROC AUC. The decision threshold is chosen on the training set to detect at least 80% of strokes.
DIn charts


EWhat I take from it
Our first version showed 95% accuracy while missing four strokes out of five, and contained a target leak in the BMI imputation. After fixing it and choosing a suitable metric, the model becomes usable as a first screening. However, it produces many false alarms and relies almost entirely on age: the limit comes from the available variables, not from the algorithm.