Spaces:
Running
Running
File size: 955 Bytes
bad208b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
from fastapi import FastAPI
from pydantic import BaseModel
import joblib
import numpy as np
class SepssisInput(BaseModel):
PRG:float
PL:float
PR:float
SK:float
TS:float
M11:float
Age:float
Insurance:int
model=joblib.load("models/sepssis_model_v1.pkl")
app=FastAPI()
@app.get("/")
def home_page():
return "Welcome to the API "
@app.post("/predict")
def inference_sepssis(sepssis_features:SepssisInput):
input_data=np.array([[
sepssis_features.PRG,
sepssis_features.PL,
sepssis_features.PR,
sepssis_features.SK,
sepssis_features.TS,
sepssis_features.M11,
sepssis_features.Age,
sepssis_features.Insurance
]])
label_predict=model.predict(input_data)
sepssis_mapping={
0:"Negative",
1:"Positive"
}
clase_predict=sepssis_mapping[label_predict[0]]
return {"Predict_for_Sepssis":clase_predict}
|