-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
32 lines (28 loc) · 831 Bytes
/
app.py
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
from fastapi import FastAPI
import uvicorn
import pickle
from models import Women
app=FastAPI()
model=pickle.load(open("diabetes.pkl","rb"))
@app.post("/predict")
def predict(req:Women):
preg=req.pregnancies
glucose=req.glucose
bp=req.bp
skinthickness=req.skinthickness
insulin=req.insulin
bmi=req.bmi
dpf=req.dpf
age=req.age
features=list([preg,glucose,bp,skinthickness,insulin,
bmi,
dpf,
age])
predict=model.predict([features])
probab=model.predict_proba([features])
if(predict==1):
return {"ans":"You have been tested positive with {} probability".format(probab[0][1])}
else:
return {"ans":"You have been tested negative with {} probability".format(probab[0][0])}
if __name__=="__main__":
uvicorn.run(app)