Skip to content

Romilagarwal/heart-failure-prediction

Repository files navigation

πŸ«€ Heart Failure Prediction

License: MIT Python Streamlit Docker XGBoost Flask

Live Demo: Streamlit Cloud App | Repository: GitHub

πŸ“Š 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 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 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 includes feature importance analysis and hyperparameter tuning.

πŸš€ Deployment Options

1️⃣ Streamlit Web App

streamlit run heart_disease_prediction.py

Access a user-friendly interface to input patient data and receive instant predictions.

2️⃣ Flask API

python predict_flask.py

For programmatic access or integration with existing healthcare systems.

3️⃣ Docker Container

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

# 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

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

⚠️ 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.

About

πŸ«€ Machine learning system for early heart disease risk prediction using XGBoost. Features interactive Streamlit dashboard, Flask API, and Docker support. Try the live demo!

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages