This repository contains a complete machine learning project for predicting the likelihood of heart failure based on patient clinical data.
We used the Heart Failure Clinical Records Dataset from the UCI Machine Learning Repository. It includes 13 clinical features such as age, serum creatinine, ejection fraction, and more, with a binary target indicating whether the patient experienced a heart failure event.
- Data loading and preprocessing
- Training and testing multiple classification models
- Evaluation using accuracy and confusion matrix
- User-friendly web interface with Gradio
The following ML algorithms were implemented and compared:
- Logistic Regression
- Support Vector Machine (SVM)
- K-Nearest Neighbors (KNN)
- AdaBoost
- LightGBM
- Naive Bayes
- Multi-Layer Perceptron (MLP)
-
Clone the repository:
git clone https://github.com/yousef-788/heart-failure-prediction.git cd heart-failure-prediction -
Install the required packages:
pip install -r requirements.txt -
Run the Gradio app:
python app.py
This will open a local Gradio interface in your browser for real-time prediction.
app.py– The main Python script running the ML model and Gradio interfaceapp.ipynb– Jupyter notebook used for development and explorationheart_failure_clinical_records_dataset.csv– The datasetrequirements.txt– List of required Python libraries
The app takes the following clinical inputs:
- Age
- Anaemia (0 or 1)
- Creatinine Phosphokinase
- Diabetes (0 or 1)
- Ejection Fraction
- High Blood Pressure (0 or 1)
- Platelets
- Serum Creatinine
- Serum Sodium
- Sex (0 = female, 1 = male)
- Smoking (0 or 1)
- Time (follow-up period in days)
The output is a binary prediction:
1: High risk of heart failure0: Low risk of heart failure
- Python
- Pandas, NumPy, Scikit-learn
- Gradio (for UI)
- Jupyter Notebook
This project is licensed under the MIT License.
Feel free to fork this repository, use it, or improve it!
