Heart Failure Prediction – Machine Learning Pipeline
📌 Problem Statement
Early detection of heart failure is critical in healthcare systems to reduce mortality risk. This project builds and evaluates multiple machine learning classification models to predict heart failure using clinical patient data, with a strong emphasis on recall optimization to minimize false negatives.
🎯 Objectives
Build an end-to-end ML classification pipeline
Compare multiple supervised learning algorithms
Prioritize medically relevant metrics (Recall, F1-score)
Select the most suitable model for healthcare risk prediction
🧠 Models Implemented
K-Nearest Neighbors (KNN)
Support Vector Classifier (SVC)
Gaussian Naive Bayes
Each model was trained and evaluated under identical preprocessing conditions to ensure a fair comparison.
⚙️ ML Pipeline & Preprocessing
Train–test split
Categorical feature encoding using One-Hot Encoding
Feature alignment to prevent train–test column mismatch
Feature scaling using StandardScaler
Model-specific preprocessing considerations
Evaluation using multiple classification metrics
📈 Evaluation Strategy
Given the medical context, recall is prioritized over accuracy.
Metrics Used:
Accuracy
Precision
Recall
F1-Score
Confusion Matrix
Classification Report
| Model | Accuracy | Precision | Recall |
|---|---|---|---|
| KNN | 90% | 85% | 84% |
| SVC | 87.5% | 90% | 88% |
| Naive Bayes | 91% | 86% | 84% |
✅ Final Model Selection: Support Vector Classifier (SVC) was selected due to its superior recall performance, making it more suitable for minimizing false negatives in a healthcare setting.
🧪 Key Engineering Insights
Accuracy is insufficient for medical classification problems
Feature scaling is critical for distance-based and margin-based models
SVC provides a robust decision boundary for clinical data
Naive Bayes offers fast inference but lower recall
Proper feature alignment prevents data leakage and runtime errors
🛠️ Tech Stack
Language: Python
Libraries: Pandas, NumPy, Scikit-learn
📌 Use Cases
Healthcare risk screening systems
Clinical decision support tools
ML model evaluation demonstrations
Visualization: Matplotlib, Seaborn
Environment: Jupyter Notebook