https://github.com/romilagarwal/heart-failure-prediction
🫀 Machine learning system for early heart disease risk prediction using XGBoost. Features interactive Streamlit dashboard, Flask API, and Docker support. Try the live demo!
https://github.com/romilagarwal/heart-failure-prediction
docker healthcare heart-disease maching-learning restful-api streamlit xgboost-classifier
Last synced: about 2 months ago
JSON representation
🫀 Machine learning system for early heart disease risk prediction using XGBoost. Features interactive Streamlit dashboard, Flask API, and Docker support. Try the live demo!
- Host: GitHub
- URL: https://github.com/romilagarwal/heart-failure-prediction
- Owner: Romilagarwal
- License: mit
- Created: 2025-02-06T19:14:01.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-10T23:28:43.000Z (about 1 year ago)
- Last Synced: 2025-06-05T06:53:39.849Z (about 1 year ago)
- Topics: docker, healthcare, heart-disease, maching-learning, restful-api, streamlit, xgboost-classifier
- Language: Jupyter Notebook
- Homepage: https://heart-failure-prediction-by-romil.streamlit.app/
- Size: 5.63 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🫀 Heart Failure Prediction
[](https://opensource.org/licenses/MIT)
[](https://www.python.org/)
[](https://heart-vs.streamlit.app/)
[](https://www.docker.com/)
[](https://xgboost.readthedocs.io/)
[](https://flask.palletsprojects.com/)
> **Live Demo**: [Streamlit Cloud App](https://heart-vs.streamlit.app/) | **Repository**: [GitHub](https://github.com/Romilagarwal/heart-failure-prediction)
## 📊 Project Overview
Cardiovascular diseases remain the **#1 cause of death globally**, claiming an estimated 17.9 million lives each year. Early detection and management are critical for people at high risk.
This machine learning system predicts heart disease risk based on clinical parameters, helping healthcare professionals identify at-risk patients earlier and potentially save lives through timely intervention.
## ✨ Key Features
- **High-accuracy prediction**: XGBoost classifier with fine-tuned parameters
- **Multiple deployment options**: Web application, API, and containerized solution
- **Interactive interface**: User-friendly Streamlit dashboard for instant predictions
- **RESTful API**: Flask backend for seamless integration with other systems
- **Docker support**: Ready for deployment in any environment
- **Cloud-deployed**: Accessible anywhere via Streamlit Cloud
## 📈 Dataset & Analysis
The model is trained on the [Heart Failure Prediction Dataset](https://www.kaggle.com/datasets/fedesoriano/heart-failure-prediction/) from Kaggle, containing key cardiovascular health indicators:
- Demographic details (age, sex)
- Clinical parameters (blood pressure, cholesterol levels)
- Symptoms (chest pain type, exercise-induced angina)
- Test results (resting ECG, max heart rate, ST depression)
Our extensive [exploratory data analysis](https://github.com/Romilagarwal/heart-failure-prediction/blob/main/notebook/part_1_preprocessing.ipynb) reveals critical patterns between these variables and heart disease risk.
## 🧠 Model Development
The project evaluates multiple classification algorithms:
- Logistic Regression
- Decision Tree Classifier
- Random Forest Classifier
- XGBoost Classifier
After rigorous comparison using confusion matrices and AUC scoring, **XGBoost** emerged as the top performer. The [complete modeling process](https://github.com/Romilagarwal/heart-failure-prediction/blob/main/notebook/part_2_modeling.ipynb) includes feature importance analysis and hyperparameter tuning.
## 🚀 Deployment Options
### 1️⃣ Streamlit Web App
```bash
streamlit run heart_disease_prediction.py
```
Access a user-friendly interface to input patient data and receive instant predictions.
### 2️⃣ Flask API
```bash
python predict_flask.py
```
For programmatic access or integration with existing healthcare systems.
### 3️⃣ Docker Container
```bash
docker build -t heart-prediction-app .
docker run -it -p 9696:9696 --rm --name heart_app heart-prediction-app:latest
```
Deploy anywhere with consistent environment and dependencies.
## 🛠️ Setup & Installation
### Prerequisites
- Python 3.7+
- pip package manager
### Quick Start
```bash
# Clone repository
git clone https://github.com/Romilagarwal/heart-failure-prediction.git
cd heart-failure-prediction
# Set up virtual environment
pip install pipenv
pipenv install
pipenv shell
# Run the app
streamlit run heart_disease_prediction.py
```
### Testing the API
```bash
python predict_flask_test.py
```
Example output:
```
{'hasHeartDisease': True, 'hasHeartDisease_probability': 0.73}
Potentially at risk of heart disease. Follow-up examination recommended.
```
## 📚 Additional Resources
- [Model training script](https://github.com/Romilagarwal/heart-failure-prediction/blob/main/training.py)
- [Docker installation guide](https://docs.docker.com/engine/install/)
- [Streamlit Cloud deployment](https://docs.streamlit.io/deploy/streamlit-community-cloud/deploy-your-app)
## ⚠️ Disclaimer
This tool is designed for **screening purposes only** and should not replace professional medical advice. Always consult healthcare providers for proper diagnosis.
## 🤝 Contributing
Contributions to improve the model accuracy, user interface, or add new features are welcome. Please feel free to submit a pull request.
## 📄 License
This project is available under the MIT License.
---
Building healthier futures through machine learning and predictive analytics.