Spaces:
Runtime error
Runtime error
Lambang
commited on
Commit
·
880a3ee
1
Parent(s):
08727d6
upp
Browse files- .gitattributes +1 -2
- README.md +5 -9
- main.py +63 -0
- ml_sepsis.pkl +3 -0
- requirements.txt +0 -0
.gitattributes
CHANGED
@@ -25,11 +25,10 @@
|
|
25 |
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
25 |
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
|
|
28 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
@@ -1,10 +1,6 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
colorTo: purple
|
6 |
sdk: docker
|
7 |
-
pinned: false
|
8 |
-
---
|
9 |
-
|
10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
+
title: FastAPI In Docker
|
2 |
+
emoji: 🐢
|
3 |
+
colorFrom: yellow
|
4 |
+
colorTo: red
|
|
|
5 |
sdk: docker
|
6 |
+
pinned: false
|
|
|
|
|
|
main.py
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
import pickle
|
3 |
+
import uvicorn
|
4 |
+
import pandas as pd
|
5 |
+
|
6 |
+
app = FastAPI()
|
7 |
+
|
8 |
+
# @app.get("/")
|
9 |
+
# def read_root():
|
10 |
+
# return {"Hello": "World!"}
|
11 |
+
|
12 |
+
|
13 |
+
# Function to load pickle file
|
14 |
+
def load_pickle(filename):
|
15 |
+
with open(filename, 'rb') as file:
|
16 |
+
data = pickle.load(file)
|
17 |
+
return data
|
18 |
+
|
19 |
+
# Load pickle file
|
20 |
+
ml_components = load_pickle('ml_sepsis.pkl')
|
21 |
+
|
22 |
+
# Components in the pickle file
|
23 |
+
ml_model = ml_components['model']
|
24 |
+
pipeline_processing = ml_components['pipeline']
|
25 |
+
|
26 |
+
#Endpoints
|
27 |
+
#Root endpoints
|
28 |
+
@app.get("/")
|
29 |
+
def root():
|
30 |
+
return {"API": "An API for Sepsis Prediction."}
|
31 |
+
|
32 |
+
@app.get('/Predict_Sepsis')
|
33 |
+
async def predict(Plasma_glucose: int, Blood_Work_Result_1: int,
|
34 |
+
Blood_Pressure: int, Blood_Work_Result_2: int,
|
35 |
+
Blood_Work_Result_3: int, Body_mass_index: float,
|
36 |
+
Blood_Work_Result_4: float,Age: int, Insurance:float):
|
37 |
+
|
38 |
+
data = pd.DataFrame({'Plasma glucose': [Plasma_glucose], 'Blood Work Result-1': [Blood_Work_Result_1],
|
39 |
+
'Blood Pressure': [Blood_Pressure], 'Blood Work Result-2': [Blood_Work_Result_2],
|
40 |
+
'Blood Work Result-3': [Blood_Work_Result_3], 'Body mass index': [Body_mass_index],
|
41 |
+
'Blood Work Result-4': [Blood_Work_Result_4], 'Age': [Age], 'Insurance':[Insurance]})
|
42 |
+
|
43 |
+
data_prepared = pipeline_processing.transform(data)
|
44 |
+
|
45 |
+
model_output = ml_model.predict(data_prepared).tolist()
|
46 |
+
|
47 |
+
prediction = make_prediction(model_output)
|
48 |
+
|
49 |
+
return prediction
|
50 |
+
|
51 |
+
|
52 |
+
|
53 |
+
|
54 |
+
def make_prediction(data_prepared):
|
55 |
+
|
56 |
+
output_pred = data_prepared
|
57 |
+
|
58 |
+
if output_pred == 0:
|
59 |
+
output_pred = "Sepsis status is Negative"
|
60 |
+
else:
|
61 |
+
output_pred = "Sepsis status is Positive"
|
62 |
+
|
63 |
+
return output_pred
|
ml_sepsis.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:97255d7da1d3d172bc0d27e1a93cab01854d05204834d08c40c80adcf4f6fb22
|
3 |
+
size 29225
|
requirements.txt
ADDED
Binary file (122 Bytes). View file
|
|