Spaces:
Runtime error
Runtime error
File size: 2,478 Bytes
585c3d8 0c290f3 585c3d8 6b3f6cb 585c3d8 c2b785c 585c3d8 c2b785c 585c3d8 6bfd5ec 585c3d8 24fc9d6 fd8b73c 585c3d8 0679215 |
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
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*365],
"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="Tiene un riesgo alto de sufrir problemas cardiovasculares"
else:
predicted="Su riesgo de sufrir problemas cardiovasculares es muy bajo. Siga as铆."
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,True,120,80,"High","Normal",0,0,1,168,62,21],
[35,False,150,60,"Very High","Normal",0,0,1,143,52,31],
[60,True,160,70,"High","High",1,1,0,185,90,23],
],
interpretation="default",
title = 'Calculadora de Riesgo Cardiovascular mediante Inteligencia Artificial',
description = 'El proyecto de CARDIOSIGHT nace debido a la presente necesidad en nuestro pa铆s de crear m茅todos y herramientas de identificaci贸n temprana para los individuos con alto riesgo de sufrir enfermedades cardiovasculares. Con el fin de prevenir eventos card铆acos primarios y ayudar a disminuir la incidencia de nuevos casos, por medio de h谩bitos de prevenci贸n. Mas informaci贸n: https://saturdays.ai/2022/03/16/cardiosight-machine-learning-para-calcular-riesgo-cardiovascular/',
theme = 'grass'
)
iface.launch() |