Beladiaamy commited on
Commit
df5eaed
·
verified ·
1 Parent(s): fe1d5f8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -16,7 +16,21 @@ explainer = shap.Explainer(loaded_model) # PLEASE DO NOT CHANGE THIS.
16
  def main_func(HighBP, HighChol, CholCheck, BMI, Smoker, Stroke, HeartDiseaseorAttack, PhysActivity, Fruits, Veggies, HvyAlcoholConsump, AnyHealthcare, NoDocbcCost, GenHlth, MentHlth, PhysHlth, DiffWalk, Sex, Age, Education, Income):
17
  new_row = pd.DataFrame.from_dict({'HighBP': HighBP, 'HighChol': HighChol, 'CholCheck': CholCheck, 'BMI': BMI, 'Smoker': Smoker, 'Stroke': Stroke, 'HeartDiseaseorAttack': HeartDiseaseorAttack, 'PhysActivity':PhysActivity, 'Fruits':Fruits, 'Veggies':Veggies, 'HvyAlcoholConsump': HvyAlcoholConsump, 'AnyHealthcare': AnyHealthcare, 'NoDocbcCost': NoDocbcCost, 'GenHlth': GenHlth, 'MentHlth': MentHlth, 'PhysHlth': PhysHlth, 'DiffWalk': DiffWalk, 'Sex': Sex, 'Age': Age, 'Education': Education, 'Income': Income},
18
  orient = 'index').transpose()
19
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  prob = loaded_model.predict_proba(new_row)
21
  shap_values = explainer(new_row)
22
  # plot = shap.force_plot(shap_values[0], matplotlib=True, figsize=(30,30), show=False)
@@ -160,6 +174,13 @@ with gr.Blocks(title=title) as demo:
160
  numeric_value = map_HighBP(HighBP_Checked)
161
  print(numeric_value)
162
 
 
 
 
 
 
 
 
163
  def map_PhysActivity(value):
164
  mapping = {'No': 0, 'Yes': 1}
165
  return mapping[value]
 
16
  def main_func(HighBP, HighChol, CholCheck, BMI, Smoker, Stroke, HeartDiseaseorAttack, PhysActivity, Fruits, Veggies, HvyAlcoholConsump, AnyHealthcare, NoDocbcCost, GenHlth, MentHlth, PhysHlth, DiffWalk, Sex, Age, Education, Income):
17
  new_row = pd.DataFrame.from_dict({'HighBP': HighBP, 'HighChol': HighChol, 'CholCheck': CholCheck, 'BMI': BMI, 'Smoker': Smoker, 'Stroke': Stroke, 'HeartDiseaseorAttack': HeartDiseaseorAttack, 'PhysActivity':PhysActivity, 'Fruits':Fruits, 'Veggies':Veggies, 'HvyAlcoholConsump': HvyAlcoholConsump, 'AnyHealthcare': AnyHealthcare, 'NoDocbcCost': NoDocbcCost, 'GenHlth': GenHlth, 'MentHlth': MentHlth, 'PhysHlth': PhysHlth, 'DiffWalk': DiffWalk, 'Sex': Sex, 'Age': Age, 'Education': Education, 'Income': Income},
18
  orient = 'index').transpose()
19
+ HighBP = map_HighBP(HighBP_Checked)
20
+ HighChol = map_HighChol(HighChol_Checked)
21
+ CholCheck = map_CholCheck(CholCheck_Checked)
22
+ Smoker = map_Smoker(Smoker_Checked)
23
+ Stroke = map_Stroke(Stroke_Checked)
24
+ HeartDiseaseorAttack = map_HeartDiseaseorAttack(HeartDiseaseorAttack_Checked)
25
+ PhysActivity = map_PhysActivity(PhysActivity_Checked)
26
+ Fruits = map_Fruits(Fruits_Checked)
27
+ Veggies = map_VeggiesCheck(Veggies_Checked)
28
+ HvyAlcoholConsump = map_HvyAlcoholConsump(HvyAlcoholConsump_Checked)
29
+ AnyHealthcare = map_AnyHealthcare(AnyHealthcare_Checked)
30
+ NoDocbcCost = map_NoDocbcCost(NoDocbcCost_Checked)
31
+ DiffWalk = map_DiffWalk(DiffWalk_Checked)
32
+
33
+
34
  prob = loaded_model.predict_proba(new_row)
35
  shap_values = explainer(new_row)
36
  # plot = shap.force_plot(shap_values[0], matplotlib=True, figsize=(30,30), show=False)
 
174
  numeric_value = map_HighBP(HighBP_Checked)
175
  print(numeric_value)
176
 
177
+ def map_HeartDiseaseorAttack(value):
178
+ mapping = {'No': 0, 'Yes': 1}
179
+ return mapping[value]
180
+ HeartDiseaseorAttack_Checked = 'Yes'
181
+ numeric_value = map_HeartDiseaseorAttack(HeartDiseaseorAttack_Checked)
182
+ print(numeric_value)
183
+
184
  def map_PhysActivity(value):
185
  mapping = {'No': 0, 'Yes': 1}
186
  return mapping[value]