MorettiGS commited on
Commit
c28c5f4
1 Parent(s): cab83d4
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -24,6 +24,8 @@ columns = [
24
  "SkinCancer"
25
  ]
26
 
 
 
27
 
28
  def predict(
29
  BMI,
@@ -55,7 +57,7 @@ def predict(
55
  MentalHealth,
56
  DiffWalking,
57
  Sex,
58
- AgeEstimate,
59
  Race+1,
60
  Diabetic,
61
  PhysicalActivity,
@@ -68,7 +70,10 @@ def predict(
68
  ]
69
  )
70
  pred = rf.predict(data)[0]
71
- return {"HeartDisease": pred}
 
 
 
72
 
73
 
74
  inputs = [
@@ -92,7 +97,7 @@ inputs = [
92
  '65-69',
93
  '70-74',
94
  '75-79',
95
- '80 or older'], type="index", label="Age Category"),
96
  gr.Dropdown(["White", "Black", "Asian", "American Indian/Alaskan Native", "Hispanic", "Other"], type="index", label="Race"),
97
  gr.Dropdown(["No", "Yes", "Yes(during pregnancy)", "No, borderline diabetes"], type="index", label="Diebetic"),
98
  gr.Checkbox(label="Physical Activity"),
@@ -103,13 +108,10 @@ inputs = [
103
  gr.Checkbox(label="Skin Cancer"),
104
  ]
105
 
106
-
107
- output = gr.Label(num_top_classes=1)
108
-
109
  iface = gr.Interface(
110
  fn=predict,
111
  inputs=inputs,
112
- outputs=output,
113
  description="The purpose of this model is to predict whether or not a person has any heart diseases or not.",
114
  )
115
 
 
24
  "SkinCancer"
25
  ]
26
 
27
+ def convert_to_int(s):
28
+ return int(s[:2])
29
 
30
  def predict(
31
  BMI,
 
57
  MentalHealth,
58
  DiffWalking,
59
  Sex,
60
+ convert_to_int(AgeEstimate),
61
  Race+1,
62
  Diabetic,
63
  PhysicalActivity,
 
70
  ]
71
  )
72
  pred = rf.predict(data)[0]
73
+ if pred == 1:
74
+ return "Has heart disease"
75
+ else:
76
+ return "Does not have any heart disease"
77
 
78
 
79
  inputs = [
 
97
  '65-69',
98
  '70-74',
99
  '75-79',
100
+ '80 or older'], label="Age Category"),
101
  gr.Dropdown(["White", "Black", "Asian", "American Indian/Alaskan Native", "Hispanic", "Other"], type="index", label="Race"),
102
  gr.Dropdown(["No", "Yes", "Yes(during pregnancy)", "No, borderline diabetes"], type="index", label="Diebetic"),
103
  gr.Checkbox(label="Physical Activity"),
 
108
  gr.Checkbox(label="Skin Cancer"),
109
  ]
110
 
 
 
 
111
  iface = gr.Interface(
112
  fn=predict,
113
  inputs=inputs,
114
+ outputs="text",
115
  description="The purpose of this model is to predict whether or not a person has any heart diseases or not.",
116
  )
117