Cardiosight / app.py
KikoDM's picture
Update app.py
0c290f3
raw
history blame
1.72 kB
import gradio as gr
import pandas as pd
from joblib import load
def cardio(age,is_male,ap_hi,ap_lo,cholesterol,gluc,smoke,alco,active,height,weight,BMI):
model = load('cardiosight.joblib')
df = pd.DataFrame.from_dict(
{
"age": [age],
"gender":[0 if is_male else 1],
"ap_hi": [ap_hi],
"ap_lo": [ap_lo],
"cholesterol": [cholesterol + 1],
"gluc": [gluc + 1],
"smoke":[1 if smoke else 0],
"alco": [1 if alco else 0],
"active": [1 if active else 0],
"newvalues_height": [height],
"newvalues_weight": [weight],
"New_values_BMI": [BMI],
}
)
pred = model.predict(df)[0]
if pred==1:
predicted="Risk"
else:
predicted="Not Risk"
return predicted
iface = gr.Interface(
cardio,
[
gr.inputs.Slider(1,99,label="Age"),
"checkbox",
gr.inputs.Slider(10,250,label="Diastolic Preassure"),
gr.inputs.Slider(10,250,label="Sistolic Preassure"),
gr.inputs.Radio(["Normal","High","Very High"],type="index",label="Cholesterol"),
gr.inputs.Radio(["Normal","High","Very High"],type="index",label="Glucosa Level"),
"checkbox",
"checkbox",
"checkbox",
gr.inputs.Slider(30,220,label="Height in cm"),
gr.inputs.Slider(10,300,label="Weight in Kg"),
gr.inputs.Slider(1,50,label="BMI"),
],
"text",
examples=[
[40,0,120,80,2,1,0,0,1,168,62,21],
[35,1,150,60,1,0,0,0,1,143,52,31],
[60,0,160,70,1,1,1,1,0,185,90,23],
],
interpretation="default",
)
iface.launch(debug=True)