Commit
·
b7b4ea5
1
Parent(s):
c5a0e19
Upload 4 files
Browse filesAdd project files
- app.py +62 -0
- pipeline.pkl +3 -0
- requirements.txt +133 -0
- sepsis.py +14 -0
app.py
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# 1. Library imports
|
2 |
+
import uvicorn
|
3 |
+
from fastapi import FastAPI
|
4 |
+
from sepsis import Sepsis
|
5 |
+
import numpy as np
|
6 |
+
import pickle
|
7 |
+
import pandas as pd
|
8 |
+
# 2. Create the app object
|
9 |
+
app = FastAPI()
|
10 |
+
with open('pipeline.pkl', 'rb') as file:
|
11 |
+
classifier_dict = pickle.load(file)
|
12 |
+
|
13 |
+
# Extract the classifier from the dictionary
|
14 |
+
classifier = classifier_dict['model']
|
15 |
+
#classifier=pickle.load(pickle_in)
|
16 |
+
|
17 |
+
# 3. Index route, opens automatically on http://127.0.0.1:8000
|
18 |
+
@app.get('/')
|
19 |
+
def index():
|
20 |
+
return {'message': 'Hello'}
|
21 |
+
|
22 |
+
# 4. Route with a single parameter, returns the parameter within a message
|
23 |
+
# Located at: http://127.0.0.1:8000/AnyNameHere
|
24 |
+
@app.get('/{name}')
|
25 |
+
def get_name(name: str):
|
26 |
+
return {'Welcome the Sepssis prediction model': f'{name}'}
|
27 |
+
|
28 |
+
# 3. Expose the prediction functionality, make a prediction from the passed
|
29 |
+
# JSON data and return the predicted Bank Note with the confidence
|
30 |
+
@app.post('/predict')
|
31 |
+
def predict_sepssis(data:Sepsis):
|
32 |
+
data = data.dict()
|
33 |
+
Plasmaglucose=data['Plasmaglucose']
|
34 |
+
BloodWorkResult1=data['BloodWorkResult1']
|
35 |
+
BloodPressure=data['BloodPressure']
|
36 |
+
BloodWorkResult2=data['BloodWorkResult2']
|
37 |
+
BloodWorkResult3=data['BloodWorkResult3']
|
38 |
+
Bodymassindex =data['Bodymassindex']
|
39 |
+
BloodWorkResult4=data['BloodWorkResult4']
|
40 |
+
Age=data['Age']
|
41 |
+
|
42 |
+
|
43 |
+
|
44 |
+
|
45 |
+
# print(classifier.predict([[variance,skewness,curtosis,entropy]]))
|
46 |
+
# Extract the classifier from the dictionary
|
47 |
+
|
48 |
+
prediction = classifier.predict([[Plasmaglucose,BloodWorkResult1,BloodPressure,BloodWorkResult2,BloodWorkResult3,Bodymassindex,BloodWorkResult4,Age]])
|
49 |
+
if(prediction[0]>0.5):
|
50 |
+
prediction="Sepssis present"
|
51 |
+
else:
|
52 |
+
prediction="Sepssis Absent"
|
53 |
+
return {
|
54 |
+
'prediction': prediction
|
55 |
+
}
|
56 |
+
|
57 |
+
# 5. Run the API with uvicorn
|
58 |
+
# Will run on http://127.0.0.1:8000
|
59 |
+
if __name__ == '__main__':
|
60 |
+
uvicorn.run(app, host='127.0.0.1', port=8000)
|
61 |
+
|
62 |
+
#uvicorn app:app --reload
|
pipeline.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5cf9ad5902a355addda0e27ed473ba6d2e4b7e53cf3c0d17546377a0929a9e45
|
3 |
+
size 3889
|
requirements.txt
ADDED
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
aiofiles==23.1.0
|
2 |
+
aiohttp==3.8.4
|
3 |
+
aiosignal==1.3.1
|
4 |
+
altair==4.2.2
|
5 |
+
anyio==3.6.2
|
6 |
+
asttokens==2.2.1
|
7 |
+
async-timeout==4.0.2
|
8 |
+
attrs==23.1.0
|
9 |
+
backcall==0.2.0
|
10 |
+
blinker==1.6.2
|
11 |
+
cachetools==5.3.0
|
12 |
+
certifi==2022.12.7
|
13 |
+
charset-normalizer==3.1.0
|
14 |
+
cleantext==1.1.4
|
15 |
+
click==8.1.3
|
16 |
+
colorama==0.4.6
|
17 |
+
comm==0.1.3
|
18 |
+
contourpy==1.0.7
|
19 |
+
cycler==0.11.0
|
20 |
+
debugpy==1.6.7
|
21 |
+
decorator==5.1.1
|
22 |
+
docker==6.1.2
|
23 |
+
entrypoints==0.4
|
24 |
+
executing==1.2.0
|
25 |
+
fastapi==0.95.1
|
26 |
+
ffmpy==0.3.0
|
27 |
+
filelock==3.12.0
|
28 |
+
fonttools==4.39.4
|
29 |
+
frozenlist==1.3.3
|
30 |
+
fsspec==2023.4.0
|
31 |
+
future==0.18.3
|
32 |
+
gitdb==4.0.10
|
33 |
+
GitPython==3.1.31
|
34 |
+
gradio==3.30.0
|
35 |
+
gradio_client==0.2.4
|
36 |
+
h11==0.14.0
|
37 |
+
httpcore==0.17.0
|
38 |
+
httpx==0.24.0
|
39 |
+
huggingface-hub==0.14.1
|
40 |
+
idna==3.4
|
41 |
+
imbalanced-learn==0.10.1
|
42 |
+
importlib-metadata==6.6.0
|
43 |
+
ipykernel==6.23.0
|
44 |
+
ipython==8.13.2
|
45 |
+
jedi==0.18.2
|
46 |
+
Jinja2==3.1.2
|
47 |
+
joblib==1.2.0
|
48 |
+
jsonschema==4.17.3
|
49 |
+
jupyter_client==8.2.0
|
50 |
+
jupyter_core==5.3.0
|
51 |
+
kiwisolver==1.4.4
|
52 |
+
linkify-it-py==2.0.2
|
53 |
+
markdown-it-py==2.2.0
|
54 |
+
MarkupSafe==2.1.2
|
55 |
+
matplotlib==3.7.1
|
56 |
+
matplotlib-inline==0.1.6
|
57 |
+
mdit-py-plugins==0.3.3
|
58 |
+
mdurl==0.1.2
|
59 |
+
mpmath==1.2.1
|
60 |
+
multidict==6.0.4
|
61 |
+
nest-asyncio==1.5.6
|
62 |
+
networkx==3.0
|
63 |
+
nltk==3.8.1
|
64 |
+
numpy==1.24.3
|
65 |
+
orjson==3.8.12
|
66 |
+
packaging==23.1
|
67 |
+
pandas==2.0.1
|
68 |
+
parso==0.8.3
|
69 |
+
pickleshare==0.7.5
|
70 |
+
Pillow==9.5.0
|
71 |
+
platformdirs==3.5.0
|
72 |
+
plotly==5.14.1
|
73 |
+
prompt-toolkit==3.0.38
|
74 |
+
protobuf==3.20.3
|
75 |
+
psutil==5.9.5
|
76 |
+
pure-eval==0.2.2
|
77 |
+
pyarrow==12.0.0
|
78 |
+
pydantic==1.10.7
|
79 |
+
pydeck==0.8.1b0
|
80 |
+
pydub==0.25.1
|
81 |
+
Pygments==2.15.1
|
82 |
+
Pympler==1.0.1
|
83 |
+
pyngrok==4.1.1
|
84 |
+
pyparsing==3.0.9
|
85 |
+
pyrsistent==0.19.3
|
86 |
+
python-dateutil==2.8.2
|
87 |
+
python-multipart==0.0.6
|
88 |
+
pytz==2023.3
|
89 |
+
pytz-deprecation-shim==0.1.0.post0
|
90 |
+
pywin32==306
|
91 |
+
PyYAML==6.0
|
92 |
+
pyzmq==25.0.2
|
93 |
+
regex==2023.5.5
|
94 |
+
requests==2.30.0
|
95 |
+
rich==13.3.5
|
96 |
+
scikit-learn==1.2.2
|
97 |
+
scipy==1.10.1
|
98 |
+
seaborn==0.12.2
|
99 |
+
semantic-version==2.10.0
|
100 |
+
six==1.16.0
|
101 |
+
smmap==5.0.0
|
102 |
+
sniffio==1.3.0
|
103 |
+
stack-data==0.6.2
|
104 |
+
starlette==0.26.1
|
105 |
+
streamlit==1.22.0
|
106 |
+
sympy==1.11.1
|
107 |
+
tenacity==8.2.2
|
108 |
+
textblob==0.17.1
|
109 |
+
threadpoolctl==3.1.0
|
110 |
+
tokenizers==0.13.3
|
111 |
+
toml==0.10.2
|
112 |
+
toolz==0.12.0
|
113 |
+
torch==2.0.1+cu117
|
114 |
+
torchaudio==2.0.2+cu117
|
115 |
+
torchvision==0.15.2+cu117
|
116 |
+
tornado==6.3.1
|
117 |
+
tqdm==4.65.0
|
118 |
+
traitlets==5.9.0
|
119 |
+
transformers==4.28.1
|
120 |
+
typing_extensions==4.5.0
|
121 |
+
tzdata==2023.3
|
122 |
+
tzlocal==4.3
|
123 |
+
uc-micro-py==1.0.2
|
124 |
+
urllib3==2.0.2
|
125 |
+
uvicorn==0.22.0
|
126 |
+
vaderSentiment==3.3.2
|
127 |
+
validators==0.20.0
|
128 |
+
watchdog==3.0.0
|
129 |
+
wcwidth==0.2.6
|
130 |
+
websocket-client==1.5.1
|
131 |
+
websockets==11.0.3
|
132 |
+
yarl==1.9.2
|
133 |
+
zipp==3.15.0
|
sepsis.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pydantic import BaseModel
|
2 |
+
# 2. Class which describes Bank Notes measurements
|
3 |
+
class Sepsis(BaseModel):
|
4 |
+
Plasmaglucose:float
|
5 |
+
BloodWorkResult1:float
|
6 |
+
BloodPressure:float
|
7 |
+
BloodWorkResult2:float
|
8 |
+
BloodWorkResult3: float
|
9 |
+
Bodymassindex: float
|
10 |
+
BloodWorkResult4: float
|
11 |
+
Age: float
|
12 |
+
|
13 |
+
|
14 |
+
|