Heart Disease Prediction with Logistic Regression
A 4-person comparative ML study on the UCI Heart Disease dataset. I owned the logistic regression model and the Introduction/Background section. The model reached a holdout ROC-AUC of 0.939, and its largest coefficients matched known clinical risk factors.
The Question
Can a simple model reason like a clinician?
Can an interpretable model predict heart disease from a routine cardiology workup, and does it weigh the same factors a clinician would? We used the UCI Heart Disease dataset (Cleveland, 303 patients, 13 clinical features).
Each teammate built a different model on the same preprocessing so the results could be compared fairly. Mine was logistic regression, chosen because every coefficient can be read and checked.
Accuracy vs. explanation
Complex models can score well but can't say why. A clinician who has to defend a recommendation needs the why.
Logistic regression
Coefficients show exactly how much each feature pushes the prediction up or down.
The Pipeline
Same data, same split, same metrics
Shared preprocessing. Median imputation and StandardScaler sit inside an sklearn Pipeline, so they are re-fit within each cross-validation fold and nothing leaks from test data into training.
One-hot encoding. Chest pain type, resting ECG, ST slope and thalassemia are categories, not ordered numbers. One-hot encoding them gave 18 model features in total.
Two kinds of evaluation. Stratified 5-fold cross-validation for a stable estimate, plus an 80/20 holdout split (seed 42) the model never trained on.
I pushed the team early to lock in the shared preprocessing and a common metrics format before anyone trained a model. Both were adopted.
| Metric | 5-fold CV (mean ± SD) | Holdout (n = 61) |
|---|---|---|
| ROC-AUC | 0.911 ± 0.020 | 0.939 |
| Accuracy | 0.848 ± 0.030 | 0.820 |
| Precision | 0.868 ± 0.051 | 0.793 |
| Recall | 0.821 | |
| F1 | 0.807 |
Reading the Model
The top coefficients match the clinical literature
| Feature | Coefficient | Clinical meaning |
|---|---|---|
| ca (major vessels on fluoroscopy) | +1.15 | Direct anatomical evidence of coronary disease |
| Asymptomatic chest pain | +0.87 | In this dataset, mostly incidental findings during a workup |
| Male sex | +0.74 | Non-modifiable cardiovascular risk factor |
| Reversible thalassemia defect | +0.68 | Ischemic but viable heart muscle on imaging |
| Flat ST slope | +0.60 | Classic ECG sign of ischemia during exercise |
| Max exercise heart rate | −0.36 | Strongest protective factor: higher capacity, lower risk |
These line up with the risk factors I wrote up in the report's Background section, which was the point of choosing a model you can read.
Reflection
What I would add
ROC-AUC measures ranking, not whether a predicted 70% really means 70%. A calibration check is the next step for any model meant to inform a decision.
A 0.5 cutoff is rarely right for screening, where a missed case costs more than an extra test. The operating point should be chosen on purpose.
An overall AUC can hide a model that works well for one group and poorly for another. Breaking results out by age and sex would show that.
Interested in this work?
Interpretable ML on clinical data and fair comparisons between models. Happy to talk through the pipeline or the coefficients.