Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/singhdivyank/sweet-sense-ai
Integrate binary classifier in a website to predict diabetes. Tech: XG Boost, AWS ECS, JavaScript
https://github.com/singhdivyank/sweet-sense-ai
aws-ecs-fargate docker exploratory-data-analysis fastapi javascript supervised-machine-learning xgboost-classifier
Last synced: 12 days ago
JSON representation
Integrate binary classifier in a website to predict diabetes. Tech: XG Boost, AWS ECS, JavaScript
- Host: GitHub
- URL: https://github.com/singhdivyank/sweet-sense-ai
- Owner: singhdivyank
- Created: 2024-12-23T20:30:01.000Z (17 days ago)
- Default Branch: main
- Last Pushed: 2024-12-24T05:29:16.000Z (16 days ago)
- Last Synced: 2024-12-24T06:22:45.467Z (16 days ago)
- Topics: aws-ecs-fargate, docker, exploratory-data-analysis, fastapi, javascript, supervised-machine-learning, xgboost-classifier
- Language: Jupyter Notebook
- Homepage:
- Size: 896 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Objective
Turn a binary classifier (**XG Boost**) to predict diabetes after Exploratory Data Analysis into a Machine Learning Solution.
# Architecting the solution
The solution is intended to use a Machine Learning model to power a web application and is architected in two stages - i) model pipeline, ii) integrating into a website
## Model pipeline
A three task strategyTable1: model deployment pipeline
| S. No. | Task | Purpose | Tech |
| ------ | ---- | ------- | ---- |
| 1 | API | Model processes a request and sends a response | FastAPI |
| 2 | Containerization | wrapper that captures all dependencies | Docker |
| 3 | Deployment | run the container over a server or cloud provider | AWS |Steps associated with the model deployment pipeline:
1. Create RestAPI to recieve parameters and return the predictions
2. Containerize the API into a [Docker image](https://fastapi.tiangolo.com/deployment/docker/) and push to Docker hub
3. Deploy the container on AWS ECS### Executing FastAPI
API details
1. method: POST
2. endpoint: `/inputs`
3. body: glucose (float), insulin (float), bmi (float), age (int)
4. response: dict {"status": "diabetic/undiabetic"}Follow the steps below to create and execute the RestAPI on your local server and the [Postman Desktop Client](https://learning.postman.com/docs/getting-started/first-steps/get-postman/).
1. `cd app`
2. `pip install -r requirements.txt`
3. `python3 -m uvicorn main:app --server 127.0.0.1 --port 8001 --reload`![](img/apiExecution.png)
Figure1: API execution results
4. exit Uvicorn server once everything is working and build Docker image
a. `cd ..`
b. `docker build -t .`5. run the docker image, `docker run -d --name -p 80:80 `
6. create a repository on [docker hub](https://hub.docker.com) and push the image
a. `docker tag `
b. `docker push `
7. query the endpoint on Postman
![](img/apiExecution_Docker.png)
Figure2: executing Docker image endpoint on Postman
![](img/DockerExec.png)
Figure3: Docker image execution status
## Website Integration
### On a side note: an alternate approach
Creating a website in JavaScript and integrating the ML classifier can be avoided by using **no-code** alternatives such as [Gradio](https://www.gradio.app). As a no-code platform it creates an API to access the model from an iteractive UI. This allows one to access the model directly as a pickle file which helps avoid both containerization and deployment.
This implementation can be found in `gradio.py`. Steps to execute on Gradio
1. `pip install gradio==3.36.1`
2. `python3 gradio.py`**Note**: FastAPI is a Gradio dependency. An error may arise due to version conflict between both of them. Just search for the correct versions and install them.