Machine Learning  ·  Clinical Classification  ·  University of Delaware

Predicting Congestive Heart Failure with Machine Learning

A comparative study of seven supervised learning models — from interpretable baselines to deep neural networks — applied to a clinical dataset of 5,888 patient records to predict heart failure outcomes and evaluate the tradeoffs between accuracy and explainability.

Python scikit-learn Pandas NumPy Predictive Modeling Clinical Data
5,888
Patient Records
Clinical Dataset
7
Models Compared
DT · RF · LR · NB · KNN · SVM · DNN
95.3%
Best Accuracy
Deep Neural Network
12
Clinical Features
Cardiac & Metabolic Markers

The Clinical Problem

Congestive heart failure (CHF) affects more than 6 million Americans and carries a five-year mortality rate approaching 50%. The condition occurs when the heart can no longer pump blood efficiently, leading to fluid buildup, organ stress, and progressive decline. Early identification of high-risk patients dramatically improves outcomes — but clinical prediction remains difficult because CHF shares symptoms with many conditions, and individual risk factors interact in complex, nonlinear ways.

The core question driving this project: can a machine learning model trained on routine clinical measurements reliably classify patients by heart failure outcome? And if so, which model best balances predictive accuracy with the explainability that clinical decision-making demands?

Dataset: 5,888 patient records with 12 clinical features — including ejection fraction (percentage of blood pumped per heartbeat), serum creatinine (kidney function), serum sodium (electrolyte balance), creatinine phosphokinase, and platelets — alongside binary indicators for anaemia, diabetes, high blood pressure, sex, and smoking status. An 80/20 train-test split was used across all models.

Model Comparison

Seven Models, One Clear Winner

All models were trained on standardized features and evaluated on accuracy and F1 score. The Deep Neural Network outperformed every other model — but the gap between it and Random Forest raises a meaningful question about when 1.6 percentage points of accuracy is worth sacrificing interpretability.

Confusion Matrix  ·  Best Model

Deep Neural Network

Test set: 1,178 patients (20% holdout)

Predicted
Healthy
Predicted
CHF
Actual
451
True Negative
20
False Positive
35
False Negative
672
True Positive

Reading the Results

The DNN correctly classified 1,123 of 1,178 test patients — a 95.3% accuracy rate. Of the 55 errors, 35 were false negatives (CHF patients classified as healthy) and 20 were false positives (healthy patients flagged as CHF).

In a clinical context, false negatives carry the higher cost: a missed CHF case may delay life-saving intervention. The model's 95.1% recall means it correctly identified 672 of 707 true CHF patients — strong performance, but one that warrants threshold tuning in real deployment to further minimize missed cases, even at the cost of more false alarms.

95.3%
Accuracy
97.1%
Precision
95.1%
Recall

Key tradeoff: Random Forest reached 93.7% accuracy while offering feature importance rankings — giving clinicians a clear explanation of why a patient was flagged. In practice, that interpretability may outweigh a 1.6-point accuracy gap.

Feature Analysis

What the Model Learned

Feature importance from the Random Forest reveals which clinical measurements most strongly predict CHF outcomes. Two features dominate: ejection fraction — how much blood the heart pumps per beat — and serum creatinine, a marker of kidney function. The strong signal from follow-up time reflects that longitudinal data carries real predictive power, even when encoded as a single numeric value.

Key Takeaways

01
Accuracy vs. Explainability Is a Real Tradeoff
The DNN achieved the highest accuracy (95.3%), but Random Forest — just 1.6 points behind — produced interpretable feature rankings. In high-stakes clinical settings, understanding why a model flags a patient isn't optional. The right model depends on the deployment context.
02
The Model Learned Established Clinical Relationships
Ejection fraction and serum creatinine were the top two predictors — consistent with clinical understanding that CHF and kidney disease are deeply linked. When a model's feature importance mirrors expert medical knowledge, it's a signal that the model is learning real signal, not noise.
03
Accuracy Isn't the Right Metric in Medicine
A 95.3% accurate model still misses 35 true CHF cases per 1,178 patients. In a clinical deployment, adjusting the classification threshold to minimize false negatives — accepting more false alarms — is likely the right tradeoff. Optimizing for recall over accuracy is a design choice, not a failure.