mbabazif commited on
Commit
dad31ae
1 Parent(s): 7331aa7

Add application file

Browse files
Dockerfile ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10
2
+
3
+ # Set the working directory inside the container
4
+ WORKDIR /app
5
+
6
+ # Copy the requirements.txt file into our working directory (/app) in the container
7
+ COPY requirements.txt .
8
+
9
+ # Install dependencies
10
+ RUN pip install --default-timeout=600 -r requirements.txt
11
+
12
+
13
+ # Copy the app.py file into our working directory (/app) in the container
14
+ COPY . /app
15
+
16
+
17
+ # Make port 80 available to the world outside this container
18
+ EXPOSE 80
19
+ # Command to run when the container starts
20
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80", "--reload"]
21
+
22
+
RandomForestClassifier_pipeline.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eb22a9265c6176ff84d7df1d1cf571ff70f3641841a35d63ece52b2e681bc5cc
3
+ size 1226431
encoder.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b7ac692cc8ee984ec176b119b746ee624096f88535f71bca8bcb69736d4f1cd8
3
+ size 542
main.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from pydantic import BaseModel
3
+ import joblib
4
+ import pandas as pd
5
+
6
+ # Create a FastAPI instance
7
+ app = FastAPI()
8
+
9
+ # Load the entire pipeline
10
+ sep_pipeline = joblib.load('./RandomForestClassifier_pipeline.joblib')
11
+ encoder = joblib.load('./encoder.joblib')
12
+
13
+ # Define a FastAPI instance ML model input schema
14
+ class PredictionInput(BaseModel):
15
+ PRG: int
16
+ PL: int
17
+ PR: int
18
+ SK: int
19
+ TS: int
20
+ M11: float
21
+ BD2: float
22
+ Age: int
23
+ Insurance: int
24
+
25
+ # Defining the root endpoint for the API
26
+ @app.get("/")
27
+ def index():
28
+ explanation = {
29
+ 'message': "Welcome to the Sepsis Prediction App",
30
+ 'description': "This API allows you to predict sepsis based on patient data.",
31
+ }
32
+ return explanation
33
+
34
+ @app.post("/predict")
35
+ def predict(PredictionInput: PredictionInput):
36
+ df = pd.DataFrame([PredictionInput.model_dump()])
37
+ # Make predictions using the pipeline
38
+ prediction = sep_pipeline.predict(df)
39
+
40
+ encode = encoder.inverse_transform([prediction])[0]
41
+
42
+ # Return the prediction
43
+ return {'prediction': encode }
requirements.txt ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ annotated-types==0.6.0
2
+ anyio==3.7.1
3
+ attrs==23.1.0
4
+ blinker==1.6.2
5
+ click==8.1.6
6
+ colorama==0.4.6
7
+ contourpy==1.1.1
8
+ cycler==0.12.1
9
+ exceptiongroup==1.2.0
10
+ fastapi==0.104.1
11
+ fastjsonschema==2.19.0
12
+ Flask==2.3.2
13
+ fonttools==4.45.1
14
+ h11==0.14.0
15
+ idna==3.6
16
+ imbalanced-learn==0.11.0
17
+ importlib-metadata==6.9.0
18
+ importlib-resources==6.1.1
19
+ itsdangerous==2.1.2
20
+ Jinja2==3.1.2
21
+ joblib==1.3.2
22
+ jsonschema==4.20.0
23
+ jsonschema-specifications==2023.11.2
24
+ jupyter_core==5.5.0
25
+ kiwisolver==1.4.5
26
+ MarkupSafe==2.1.3
27
+ matplotlib==3.7.4
28
+ nbformat==5.9.2
29
+ numpy==1.24.4
30
+ packaging==23.2
31
+ pandas==2.0.3
32
+ Pillow==10.1.0
33
+ pkgutil_resolve_name==1.3.10
34
+ platformdirs==4.0.0
35
+ plotly==5.18.0
36
+ pydantic==2.5.2
37
+ pydantic_core==2.14.5
38
+ pyparsing==3.1.1
39
+ python-dateutil==2.8.2
40
+ pytz==2023.3.post1
41
+ referencing==0.31.1
42
+ rpds-py==0.13.2
43
+ scikit-learn==1.3.2
44
+ scipy==1.10.1
45
+ seaborn==0.13.0
46
+ six==1.16.0
47
+ sniffio==1.3.0
48
+ starlette==0.27.0
49
+ tenacity==8.2.3
50
+ threadpoolctl==3.2.0
51
+ traitlets==5.14.0
52
+ typing_extensions==4.8.0
53
+ tzdata==2023.3
54
+ uvicorn==0.24.0.post1
55
+ Werkzeug==2.3.6
56
+ xgboost==2.0.2
57
+ zipp==3.17.0