Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- app.py +61 -0
- cardiosight.joblib +3 -0
- requirements.txt +0 -0
app.py
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
from joblib import load
|
4 |
+
|
5 |
+
def cardio(age,gender,ap_hi,ap_lo,cholesterol,gluc,smoke,alco,active,height,weight):
|
6 |
+
model = load('cardiosight.joblib')
|
7 |
+
df = pd.DataFrame.from_dict(
|
8 |
+
{
|
9 |
+
"age": [age*365],
|
10 |
+
"gender":[0 if gender=='Male' else 1],
|
11 |
+
"ap_hi": [ap_hi],
|
12 |
+
"ap_lo": [ap_lo],
|
13 |
+
"cholesterol": [cholesterol + 1],
|
14 |
+
"gluc": [gluc + 1],
|
15 |
+
"smoke":[1 if smoke=='Yes' else 0],
|
16 |
+
"alco": [1 if alco=='Yes' else 0],
|
17 |
+
"active": [1 if active=='Yes' else 0],
|
18 |
+
"newvalues_height": [height],
|
19 |
+
"newvalues_weight": [weight],
|
20 |
+
"New_values_BMI": weight/((height/100)**2),
|
21 |
+
|
22 |
+
}
|
23 |
+
)
|
24 |
+
|
25 |
+
pred = model.predict(df)[0]
|
26 |
+
if pred==1:
|
27 |
+
predicted="Tiene un riesgo alto de sufrir problemas cardiovasculares"
|
28 |
+
else:
|
29 |
+
predicted="Su riesgo de sufrir problemas cardiovasculares es muy bajo. Siga as铆."
|
30 |
+
return "Su IMC es de "+str(round(df['New_values_BMI'][0], 2))+'. '+predicted
|
31 |
+
|
32 |
+
iface = gr.Interface(
|
33 |
+
cardio,
|
34 |
+
[
|
35 |
+
gr.Slider(1,99,label="Age"),
|
36 |
+
gr.Dropdown(choices=['Male', 'Female'], label='Gender', value='Female'),
|
37 |
+
gr.Slider(10,250,label="Diastolic Preassure"),
|
38 |
+
gr.Slider(10,250,label="Sistolic Preassure"),
|
39 |
+
gr.Radio(["Normal","High","Very High"],type="index",label="Cholesterol"),
|
40 |
+
gr.Radio(["Normal","High","Very High"],type="index",label="Glucosa Level"),
|
41 |
+
gr.Dropdown(choices=['Yes', 'No'], label='Smoke', value='No'),
|
42 |
+
gr.Dropdown(choices=['Yes', 'No'], label='Alcohol', value='No'),
|
43 |
+
gr.Dropdown(choices=['Yes', 'No'], label='Active', value='Yes'),
|
44 |
+
gr.Slider(30,220,label="Height in cm"),
|
45 |
+
gr.Slider(10,300,label="Weight in Kg"),
|
46 |
+
],
|
47 |
+
|
48 |
+
"text",
|
49 |
+
examples=[
|
50 |
+
[20,'Male',110,60,"Normal","Normal",'No','No','Yes',168,60],
|
51 |
+
[30,'Female',120,70,"High","High",'No','Yes','Yes',143,70],
|
52 |
+
[40,'Male',130,80,"Very High","Very High",'Yes','Yes','No',185,80],
|
53 |
+
[50,'Female',140,90,"Normal","High",'Yes','No','No',165,90],
|
54 |
+
[60,'Male',150,100,"High","Very High",'No','No','Yes',175,100],
|
55 |
+
[70,'Female',160,90,"Very High","Normal",'Yes','Yes','No',185,110],
|
56 |
+
],
|
57 |
+
title = 'Calculadora de Riesgo Cardiovascular mediante Inteligencia Artificial',
|
58 |
+
description = 'Duplicaci贸n del proyecto de CARDIOSIGHT. He cambiado los botones tipo check por dropdown y calculado el IMC a partir de la altura y el peso. M谩s informaci贸n: https://saturdays.ai/2022/03/16/cardiosight-machine-learning-para-calcular-riesgo-cardiovascular/'
|
59 |
+
)
|
60 |
+
|
61 |
+
iface.launch()
|
cardiosight.joblib
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2be6c3effbdea5cf7b1f40ac86a2e8bd951fc60fadbf38a83c68dbd4b878f01f
|
3 |
+
size 153988639
|
requirements.txt
ADDED
Binary file (2.37 kB). View file
|
|