This project uses machine learning to predict the likelihood of heart disease based on clinical, demographic, and diagnostic features. The models are trained on the Heart Failure Prediction Dataset and can help with early detection and risk assessment.
- Python (Pandas, NumPy)
- Scikit-learn (Logistic Regression, Random Forest Classifier)
- Matplotlib & Seaborn (visualizations)
- Jupyter Notebook
- Sourced from Kaggle: Heart Failure Prediction Dataset
- 918 observations, 11 features including Age, Sex, Blood Pressure, Cholesterol, Max Heart Rate, etc.
- Binary classification:
HeartDisease(1 = yes, 0 = no)
-
Data preprocessing:
- Standardized numerical features
- Encoded categorical and binary features
- Replaced zero-values in Cholesterol with median values
-
Modeling:
- Logistic Regression for linear relationships
- Random Forest Classifier for capturing non-linear patterns
- 5-fold cross-validation using recall as the primary metric
-
Evaluation:
- Confusion matrices, accuracy, recall, F1-score
- Feature importance analysis
| Model | Accuracy | Recall (Positive) | F1-Score (Positive) |
|---|---|---|---|
| Random Forest Classifier | 0.89 | 0.89 | 0.90 |
| Logistic Regression | 0.88 | 0.87 | 0.89 |
- Random Forest slightly outperforms Logistic Regression.
- Models are promising for screening purposes but not for definitive diagnosis.
- Feature correlation heatmap
- Confusion matrices for each model
- Feature importance bar charts from Random Forest
- Use larger datasets to improve model performance
- Explore Gradient Boosting, SVMs, or Neural Networks for better non-linear pattern capture
- Tune hyperparameters for higher accuracy and recall
Open HeartDiseasePrediction.ipynb with Jupyter or Google Colab.