Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
+
from joblib import load
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def cardio(age,is_male,ap_hi,ap_lo,cholesterol,gluc,smoke,alco,active,height,weight,BMI):
|
| 8 |
+
model = load('cardiosight.joblib')
|
| 9 |
+
df = pd.DataFrame.from_dict(
|
| 10 |
+
{
|
| 11 |
+
"age": [age],
|
| 12 |
+
"gender":[0 if is_male else 1],
|
| 13 |
+
"ap_hi": [ap_hi],
|
| 14 |
+
"ap_lo": [ap_lo],
|
| 15 |
+
"cholesterol": [cholesterol + 1],
|
| 16 |
+
"gluc": [gluc + 1],
|
| 17 |
+
"smoke":[1 if smoke else 0],
|
| 18 |
+
"alco": [1 if alco else 0],
|
| 19 |
+
"active": [1 if active else 0],
|
| 20 |
+
"newvalues_height": [height],
|
| 21 |
+
"newvalues_weight": [weight],
|
| 22 |
+
"New_values_BMI": [BMI],
|
| 23 |
+
|
| 24 |
+
}
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
pred = model.predict(df)[0]
|
| 28 |
+
if pred==1:
|
| 29 |
+
predicted="Risk"
|
| 30 |
+
else:
|
| 31 |
+
predicted="Not Risk"
|
| 32 |
+
return predicted
|
| 33 |
+
|
| 34 |
+
iface = gr.Interface(
|
| 35 |
+
cardio,
|
| 36 |
+
[
|
| 37 |
+
gr.inputs.Slider(1,99,label="Age"),
|
| 38 |
+
"checkbox",
|
| 39 |
+
gr.inputs.Slider(10,250,label="Diastolic Preassure"),
|
| 40 |
+
gr.inputs.Slider(10,250,label="Sistolic Preassure"),
|
| 41 |
+
gr.inputs.Radio(["Normal","High","Very High"],type="index",label="Cholesterol"),
|
| 42 |
+
gr.inputs.Radio(["Normal","High","Very High"],type="index",label="Glucosa Level"),
|
| 43 |
+
"checkbox",
|
| 44 |
+
"checkbox",
|
| 45 |
+
"checkbox",
|
| 46 |
+
gr.inputs.Slider(30,220,label="Height in cm"),
|
| 47 |
+
gr.inputs.Slider(10,300,label="Weight in Kg"),
|
| 48 |
+
gr.inputs.Slider(1,50,label="BMI"),
|
| 49 |
+
],
|
| 50 |
+
|
| 51 |
+
"text",
|
| 52 |
+
examples=[
|
| 53 |
+
[40,0,120,80,2,1,0,0,1,168,62,21],
|
| 54 |
+
[35,1,150,60,1,0,0,0,1,143,52,31],
|
| 55 |
+
[60,0,160,70,1,1,1,1,0,185,90,23],
|
| 56 |
+
],
|
| 57 |
+
interpretation="default",
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
iface.launch(debug=True)
|