This project demonstrates transforming ML models into RESTful APIs and Graph APIs using FastAPI library, enabling easy integration into diverse applications. Learn to build ML models, create RESTful APIs, and containerize the application with Docker. This bridges the gap between ML practitioners and software engineers using different tech stacks. This repository contains data analysis, insights, and machine learning modelling for sepsis prediction including a dev folder for model developmemt in Jupyter notebooks, a src folder containing both client frontend and FastAPI backend. This is a full stack application with FastAPI Backend encompasing a RESTFul and a GraphQL APIs.
Sepsis, a life-threatening condition, arises from the body’s exaggerated response to infection. Swift intervention is essential to prevent tissue damage, organ failure, and mortality because septic shock can cause death in as little as 12 hours. Therefore, Prompt diagnosis and treatment significantly enhance survival rates for individuals with mild sepsis. Conversely, without timely intervention, advanced stages of sepsis often prove fatal. Even with optimal care, septic shock—the most critical phase of sepsis—has a mortality rate of 30% to 40%.
Early Detection:
Predict which patients in the ICU are likely to develop sepsis, allowing healthcare providers to intervene early and improve patient outcomes.
Resource Allocation:
Optimize the allocation of medical resources by focusing attention and care on high-risk patients.
Reduce Healthcare Costs:
Early detection and treatment of sepsis can decrease hospital stays and reduce the need for intensive care, leading to substantial cost savings.
Improve Operational Efficiency:
Automating sepsis prediction through advanced machine learning models reduces the burden on healthcare professionals, allowing them to focus on patient care.
The CRoss Industry Standard Process for Data Mining (CRISP-DM).
- ID: Unique Identifier of patient
- PRG(Plasma Glucose): Measurement of plasma glucose levels.
- PL(Blood Work Result 1): Blood work result in mu U/ml.
- PR(Blood Pressure): Measurement of blood pressure in mm Hg.
- SK(Blood Work Result 2): Blood work result in mm.
- TS(Blood Work Result 3): Blood work result in mu U/ml.
- M11(Body Mass Index): BMI calculated as weight in kg/(height in m)^2
- BD2(Blood Work Result 4): Blood work result in mu U/ml
- Age: Age of the patient in years.
- Insurance: Indicates whether the patient holds a valid insurance card.
- Sepsis: Target variable indicating whether the patient will develop sepsis (Positive) or (Negative)
- Preview here on Google Collab sepsis_prediction.ipynb
sepsis-fastapi-hf.mp4
sepsis-streamlit-hf.mp4
- Anaconda
- Streamlit
- Python
- Pandas
- Plotly
- Git
- Scipy
- Sklearn
- Adaboost
- Catboost
- Decision tree
- Kneighbors
- LGBM
- LogisticRegression
- RandomForest
- SVC
- XGBoost
- Joblib
pip install -r requirements.txt
conda env create -f sepsis_environment.yml
To get a local copy up and running, follow these steps.
Clone this repository to your desired folder:
cd your-folder
git clone https://github.com/D0nG4667/sepsis_prediction_full_stack.git
Change into the cloned repository
cd sepsis_prediction_full_stack
After cloning this repo,
-
Add an env folder in the root of the project.
-
Create and env file named
offline.env
using this sample
# API
API_URL=http://api:7860/api/v1/prediction?model
# Redis local
REDIS_URL=redis://cache:6379/
REDIS_USERNAME=default
- Run these commands in the root of the repo to explore the frontend and backend application:
docker-compose pull
docker-compose build
docker-compose up
- Fork the repository and clone it to your local machine.
- Explore the Jupyter Notebooks and documentation.
- Implement enhancements, fix bugs, or propose new features.
- Submit a pull request with your changes, ensuring clear descriptions and documentation.
- Participate in discussions, provide feedback, and collaborate with the community.
Feedback, suggestions, and contributions are welcome! Feel free to open an issue for bug reports, feature requests, or general inquiries. For additional support or questions, you can connect with me on LinkedIn.
Link to article on Medium: Building Machine Learning APIs with FastAPI: Embedding Machine Learning Models for Predicting Sepsis- A Full Stack Approach
🕺🏻Gabriel Okundaye
-
GitHub: GitHub Profile
-
LinkedIn: LinkedIn Profile
If you like this project kindly show some love, give it a 🌟 STAR 🌟. Thank you!
This project is MIT licensed.