Upload 8 files
Browse files- Dockerfile +37 -0
- datasets/Paitients_Files_Test.csv +1 -0
- datasets/Paitients_Files_Train.csv +1 -0
- main.py +70 -0
- notebooks/LP6-Sepsis-Predictment-And-API.ipynb +0 -0
- notebooks/seville-LP6-Copy2.ipynb +0 -0
- requirements.txt +0 -0
- xgb.joblib +3 -0
Dockerfile
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# FROM python:3.9
|
| 2 |
+
|
| 3 |
+
# WORKDIR /code
|
| 4 |
+
|
| 5 |
+
# COPY ./requirements.txt /code/requirements.txt
|
| 6 |
+
|
| 7 |
+
# RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 8 |
+
|
| 9 |
+
# COPY . .
|
| 10 |
+
|
| 11 |
+
# CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# Use the official Python image as the base image
|
| 15 |
+
#FROM python:3.9-slim
|
| 16 |
+
FROM python:3.10.6
|
| 17 |
+
|
| 18 |
+
# Set the working directory in the container
|
| 19 |
+
WORKDIR /app
|
| 20 |
+
|
| 21 |
+
# Copy the requirements file into the container
|
| 22 |
+
COPY requirements.txt .
|
| 23 |
+
|
| 24 |
+
# Install dependencies
|
| 25 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 26 |
+
|
| 27 |
+
# Copy the xgb_model.joblib files to the container
|
| 28 |
+
COPY xgb.joblib .
|
| 29 |
+
|
| 30 |
+
# Copy the current directory contents into the container at /app
|
| 31 |
+
COPY . /app
|
| 32 |
+
|
| 33 |
+
# Expose the port that the FastAPI application will run on
|
| 34 |
+
EXPOSE 7860
|
| 35 |
+
|
| 36 |
+
# Command to run the FastAPI application when the container starts
|
| 37 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
datasets/Paitients_Files_Test.csv
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
ID,PRG,PL,PR,SK,TS,M11,BD2,Age,Insurance
|
datasets/Paitients_Files_Train.csv
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
ID,PRG,PL,PR,SK,TS,M11,BD2,Age,Insurance,Sepssis
|
main.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
import uvicorn
|
| 3 |
+
import json
|
| 4 |
+
from pydantic import BaseModel
|
| 5 |
+
import joblib
|
| 6 |
+
import json
|
| 7 |
+
import imblearn
|
| 8 |
+
import pandas as pd
|
| 9 |
+
from xgboost import XGBClassifier
|
| 10 |
+
from fastapi import FastAPI, Query, Request, HTTPException
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
app = FastAPI()
|
| 15 |
+
|
| 16 |
+
# loading my best model with joblib
|
| 17 |
+
model = joblib.load("./xgb.joblib")
|
| 18 |
+
|
| 19 |
+
###
|
| 20 |
+
@app.get("/")
|
| 21 |
+
async def read_root():
|
| 22 |
+
return {"message": "Welcome to the Sepsis Prediction using FastAPI"}
|
| 23 |
+
|
| 24 |
+
def classify(prediction):
|
| 25 |
+
if prediction == 0:
|
| 26 |
+
return "Patient does not have sepsis"
|
| 27 |
+
else:
|
| 28 |
+
return "Patient has sepsis"
|
| 29 |
+
|
| 30 |
+
@app.post("/predict/")
|
| 31 |
+
async def predict_sepsis(
|
| 32 |
+
request: Request,
|
| 33 |
+
prg: float = Query(..., description="Plasma_glucose"),
|
| 34 |
+
pl: float = Query(..., description="Blood_Work_R1"),
|
| 35 |
+
pr: float = Query(..., description="Blood_Pressure"),
|
| 36 |
+
sk: float = Query(..., description="Blood_Work_R2"),
|
| 37 |
+
ts: float = Query(..., description="Blood_Work_R3"),
|
| 38 |
+
m11: float = Query(..., description="BMI"),
|
| 39 |
+
bd2: float = Query(..., description="Blood_Work_R4"),
|
| 40 |
+
age: int = Query(..., description="Age")
|
| 41 |
+
# ... (other input parameters)
|
| 42 |
+
):
|
| 43 |
+
input_data = [prg, pl, pr, sk, ts, m11, bd2, age]
|
| 44 |
+
|
| 45 |
+
input_df = pd.DataFrame([input_data], columns=[
|
| 46 |
+
"Plasma_glucose", "Blood_Work_R1", "Blood_Pressure",
|
| 47 |
+
"Blood_Work_R2", "Blood_Work_R3",
|
| 48 |
+
"BMI", "Blood_Work_R4", "Age"
|
| 49 |
+
])
|
| 50 |
+
|
| 51 |
+
pred = model.predict(input_df)
|
| 52 |
+
output = classify(pred[0])
|
| 53 |
+
|
| 54 |
+
response = {
|
| 55 |
+
"prediction": output
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
return response
|
| 59 |
+
|
| 60 |
+
# Run the app using Uvicorn
|
| 61 |
+
if __name__ == "__main__":
|
| 62 |
+
import uvicorn
|
| 63 |
+
uvicorn.run(app, host="127.0.0.1", port=7860)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
|
notebooks/LP6-Sepsis-Predictment-And-API.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
notebooks/seville-LP6-Copy2.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
requirements.txt
ADDED
|
Binary file (1.12 kB). View file
|
|
|
xgb.joblib
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c8f67e1c70c753b04cb7b68256898ba9c22b30d0e63cc58cdde831b93326bf8b
|
| 3 |
+
size 3837923
|