Spaces:
Sleeping
Sleeping
criticalDanger
commited on
Commit
•
b0ac891
1
Parent(s):
a265aea
Update app.py
Browse files
app.py
CHANGED
@@ -9,25 +9,25 @@ with open('heart_disease_model.pkl', 'rb') as file:
|
|
9 |
# Define the prediction function
|
10 |
def predict_heart_disease(male, age, currentSmoker, cigsPerDay, BPMeds, prevalentStroke, prevalentHyp, diabetes, BMI):
|
11 |
male = 1 if male == "Male" else 0
|
12 |
-
currentSmoker = 1 if currentSmoker
|
13 |
-
BPMeds = 1 if BPMeds
|
14 |
-
prevalentStroke = 1 if prevalentStroke
|
15 |
-
prevalentHyp = 1 if prevalentHyp
|
16 |
-
diabetes = 1 if diabetes
|
17 |
input_data = np.array([[male, age, currentSmoker, cigsPerDay, BPMeds, prevalentStroke, prevalentHyp, diabetes, BMI]])
|
18 |
prediction = model.predict(input_data)
|
19 |
return 'Heart Disease' if prediction[0] == 1 else 'No Heart Disease'
|
20 |
|
21 |
# Define the input components
|
22 |
inputs = [
|
23 |
-
gr.
|
24 |
gr.Number(label="Age"),
|
25 |
-
gr.
|
26 |
gr.Number(label="Number of ciggerates a day"),
|
27 |
-
gr.
|
28 |
-
gr.
|
29 |
-
gr.
|
30 |
-
gr.
|
31 |
gr.Number(value=float, label="BMI")
|
32 |
|
33 |
]
|
|
|
9 |
# Define the prediction function
|
10 |
def predict_heart_disease(male, age, currentSmoker, cigsPerDay, BPMeds, prevalentStroke, prevalentHyp, diabetes, BMI):
|
11 |
male = 1 if male == "Male" else 0
|
12 |
+
currentSmoker = 1 if currentSmoker else 0
|
13 |
+
BPMeds = 1 if BPMeds else 0
|
14 |
+
prevalentStroke = 1 if prevalentStroke else 0
|
15 |
+
prevalentHyp = 1 if prevalentHyp else 0
|
16 |
+
diabetes = 1 if diabetes else 0
|
17 |
input_data = np.array([[male, age, currentSmoker, cigsPerDay, BPMeds, prevalentStroke, prevalentHyp, diabetes, BMI]])
|
18 |
prediction = model.predict(input_data)
|
19 |
return 'Heart Disease' if prediction[0] == 1 else 'No Heart Disease'
|
20 |
|
21 |
# Define the input components
|
22 |
inputs = [
|
23 |
+
gr.Radio(choices=["Male","Female"], label="Sex"),
|
24 |
gr.Number(label="Age"),
|
25 |
+
gr.Checkbox(label="Do you smoke?"),
|
26 |
gr.Number(label="Number of ciggerates a day"),
|
27 |
+
gr.Checkbox(label="Do you take BP medicines?"),
|
28 |
+
gr.Checkbox(label="Have you had strokes previously?"),
|
29 |
+
gr.Checkbox(label="Have you had High BP previously?"),
|
30 |
+
gr.Checkbox(label="Do you have Diabetes?"),
|
31 |
gr.Number(value=float, label="BMI")
|
32 |
|
33 |
]
|