This repository contains a comprehensive data science project aimed at predicting the likelihood of a stroke based on user-provided clinical data. It integrates multiple tools and frameworks to build a full-fledged, production-ready application for healthcare professionals and medical devices.
- Medical Professionals 👨⚕️
- Clinics & Hospitals 🏥
- Medical Devices 🔬
This application allows healthcare professionals or users to input clinical and personal health data through a web interface or directly into medical devices. Our machine learning model then predicts the probability of a stroke, displaying detailed results, precautions, and recommendations for professional consultation.
- Web Interface & Data Search: Built with Streamlit for user-friendly interaction.
- Prediction API: Developed using FastAPI for real-time predictions.
- Machine Learning Model: Packaged as a Python module (
stroke-pred-p0w11
). - Data Storage: Utilizes PostgreSQL with SQLAlchemy for secure and efficient data management.
- Data Ingestion: Implemented using Apache Airflow to collect and manage user input data.
- Monitoring Dashboard: Real-time prediction monitoring with Grafana.
We utilize a dataset with 11 clinical features for predicting stroke events. You can access it here.
-
Ensure you have the necessary dependencies installed:
pip install -r Heart-Stroke-Prediction/requirements.txt
Note: For Mac/Linux users, install
psycopg2-binary
instead ofpsycopg2
. -
Create a
.env
file in the root directory (Heart-Stroke-Prediction/.env
) with the following content:[POSTGRES_DB] POSTGRES_USER=[Your_User] POSTGRES_PASSWORD=[Your_Password] POSTGRES_SERVER=[Your_Server] POSTGRES_PORT=[Your_Port] POSTGRES_DB=[Your_Database] [FastApi] BACKEND_SERVER=[Your_Server]
-
Navigate to the PostgreSQL setup directory and run the database setup script:
cd stroke_heart_prediction/postgres python createdb.py
To run the application locally, execute the following commands:
# Start the Prediction API
cd Heart-Stroke-Prediction/stroke_api
uvicorn main:app --host 0.0.0.0 --port 8005
# Start the Web Interface
streamlit run web_interface.py --server.port 8010