Live Demo: Streamlit Cloud App | Repository: GitHub
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.
- 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
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.
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.
streamlit run heart_disease_prediction.pyAccess a user-friendly interface to input patient data and receive instant predictions.
python predict_flask.pyFor programmatic access or integration with existing healthcare systems.
docker build -t heart-prediction-app .
docker run -it -p 9696:9696 --rm --name heart_app heart-prediction-app:latestDeploy anywhere with consistent environment and dependencies.
- Python 3.7+
- pip package manager
# 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.pypython predict_flask_test.pyExample output:
{'hasHeartDisease': True, 'hasHeartDisease_probability': 0.73}
Potentially at risk of heart disease. Follow-up examination recommended.
This tool is designed for screening purposes only and should not replace professional medical advice. Always consult healthcare providers for proper diagnosis.
Contributions to improve the model accuracy, user interface, or add new features are welcome. Please feel free to submit a pull request.
This project is available under the MIT License.
Building healthier futures through machine learning and predictive analytics.