Problem and who it is for

The WHO reports that cardiovascular diseases are the leading cause of death globally: an estimated 19.8 million deaths in 2022, about 32% of all deaths (WHO fact sheet, checked 2026-11-22).

The dataset describes 303 patients undergoing angiography at the Cleveland Clinic, as stated in the 1989 abstract by Detrano et al. (https://pubmed.ncbi.nlm.nih.gov/2756873/). The model asks whether a set of routine clinical measurements can rank these patients by their chance of significant narrowing (more than 50% in at least one major vessel). The eventual users would be clinicians deciding who to review first among patients waiting for angiography. This project has not tested that group. The result applies to patients who had angiography, and it is a research prototype, not a triage tool.

Method

The dataset is the UCI Heart Disease file for Cleveland: 303 patients and 13 clinical features. The label is num > 0 in the UCI file. 139 patients are positive.

I split the patients 75/25 with a stratified split (seed 42), giving 227 for training and 76 for testing. The test patients are used only for reporting. Model choice and the threshold are decided on the training data.

Two models are compared: logistic regression (C = 1.0, the scikit-learn default) and a random forest with 300 trees. I set both values in the code before the first run and did not change them. I did not run a hyperparameter search, and the test set was not used to choose either model's settings. Each model is scored with 5-fold cross-validation inside the training data, and the one with the higher AUROC is chosen. The random forest was chosen (AUROC 0.888 against 0.882). The gap is small, and across 20 repeated splits the forest was chosen 7 times.

The threshold comes from the out-of-fold probabilities of the chosen model. It minimises an expected cost in which a missed patient costs 5 times a false alarm. That 5:1 ratio is an assumption that no clinician has reviewed. I also report 1:1, 2:1 and 10:1.

Missing values (6 cells) are filled with the training median in each fold. The browser demo runs the logistic regression, because its formula can be written out in JavaScript. A check script confirms that the browser code gives the same probabilities as scikit-learn for all 303 rows.

Calibration (reliability bins on the test set, Brier score, recalibration slope) and decision curves (net benefit against "flag all" and "flag none") are also reported.

Evaluation

Metrics and measurement: on the 76 held-out test patients (35 positive), with the threshold fixed from training data. Confidence intervals: bootstrap for AUROC (1,000 resamples), Wilson for sensitivity and specificity.

Random forest (the chosen model), threshold 0.20:

  • AUROC 0.936 (95% CI 0.876 to 0.981). Brier score 0.107.
  • Sensitivity 100% (35 of 35; 95% CI 90% to 100%). Specificity 49% (20 of 41; 95% CI 34% to 64%).
  • 74% of test patients are flagged (56 of 76).

Logistic regression (the demo model), threshold 0.10:

  • AUROC 0.931 (95% CI 0.862 to 0.978). Brier score 0.103.
  • Sensitivity 100% (35 of 35). Specificity 39% (16 of 41; 95% CI 26% to 54%). 79% flagged (60 of 76).

Baselines on the same test set: age and sex only (logistic regression), AUROC 0.660, sensitivity 97%, specificity 22%. Flag everyone, AUROC 0.50.

Cost-ratio check (logistic regression): at 1:1, sensitivity 86%, specificity 88%, 46% flagged. At 2:1, sensitivity 89%, specificity 83%, 50% flagged. At 10:1, sensitivity 100%, specificity 32%, 83% flagged.

Calibration (test set): the random forest's probabilities are compressed toward the middle (recalibration slope 1.72). The logistic regression is closer to ideal (slope 1.10).

Decision curves (test set): the logistic regression and the random forest are both above "flag all" from a threshold of about 0.2 to 0.5. At 0.30 the net benefit is 0.357 for the random forest and 0.348 for the logistic regression, against 0.229 for flag-all. Below about 0.10 the gain over flag-all is small.

Stability: over 20 random splits, mean AUROC was 0.889 for the random forest (range 0.822 to 0.953) and 0.893 for the logistic regression (range 0.844 to 0.960).

Reproduce: python3 -I train_eval.py (about 40 seconds). All seeds are fixed. Outputs are in results/, and the figures are PNG files in results/.

Reading the result: the ranking is good on these 76 patients. Both models flag every test positive at their chosen thresholds, but the sample is small. At the 5:1 assumption most patients are flagged (74% for the random forest, 79% for the logistic regression), which is too broad for a shortlist. Any setting that a clinic would accept is a clinical decision.

Who benefits, and who could be harmed

Who could benefit: if a score like this were validated in patients waiting for angiography and used alongside clinical judgement, patients with significant narrowing might be reviewed earlier.

Who could be harmed:

  • A patient with significant narrowing who scores below the threshold could be reviewed later. The test set had no such patient for either model, but the 95% interval for sensitivity runs down to about 90%.
  • A patient without significant narrowing who is flagged could take extra tests and clinician time. At the 5:1 setting, the logistic regression (the demo model) flagged 25 of 41 test patients without narrowing; the random forest (the chosen model) flagged 21 of 41.
  • The data are about 68% male and come from one centre. Errors could fall unevenly on women, younger patients, other groups, or patients in current practice. This was not measured.

Limitations

  • All patients underwent angiography, so the model has not been checked on patients waiting for angiography.
  • One public dataset from one centre, donated to UCI in 1988. The collection period is not stated. No external validation.
  • 76 test patients, so the confidence intervals are wide.
  • Some inputs are coded categories (chest pain type, rest ECG, ST slope, thalassaemia test) and are used as numbers.
  • The cost ratio is a working assumption and has not been reviewed by a clinician. The threshold depends on it.
  • The demo runs the logistic regression, not the chosen random forest.
  • The demo is a research prototype and must not be used for care decisions.

What I would do with another month

  1. Find a second public dataset with a clear licence, or a cohort of patients waiting for angiography, and test the model there with the same metrics.
  2. Ask a clinician to review the task definition and set the cost ratio, then re-run the threshold choice.
  3. Recalibrate the random forest and check whether its ranking holds after recalibration.
  4. Report performance by sex and age band.

Attribution

  • Dataset: Janosi, A., Steinbrunn, W., Pfisterer, M., & Detrano, R. (1989). Heart Disease [Dataset]. UCI Machine Learning Repository. https://doi.org/10.24432/C52P4X. Licence CC BY 4.0.
  • Cohort description: Detrano, R., et al. (1989). International application of a new probability algorithm for the diagnosis of coronary artery disease. American Journal of Cardiology, 64(5), 304-310. Abstract: https://pubmed.ncbi.nlm.nih.gov/2756873/ (DOI 10.1016/0002-9149(89)90524-9)
  • Libraries: scikit-learn, pandas, numpy, matplotlib.
  • WHO fact sheet on cardiovascular diseases: https://www.who.int/news-room/fact-sheets/detail/cardiovascular-diseases-(cvds)
  • The code and documents in the repository were written for this project, with AI assistance as disclosed below.

AI tool disclosure

Claude (Anthropic, Claude Code) was used to write parts of the code, the evaluation script and this text.

Share this project:

Updates

Submission history