Beladiaamy commited on
Commit
55f0fa6
·
verified ·
1 Parent(s): 5563308

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -13,8 +13,8 @@ loaded_model = pickle.load(open("db_xgb.pkl", 'rb'))
13
  explainer = shap.Explainer(loaded_model) # PLEASE DO NOT CHANGE THIS.
14
 
15
  # Create the main function for server
16
- def main_func(Diabetes_binary, 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({'Diabetes_binary': Diabetes_binary, '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)
@@ -45,8 +45,6 @@ with gr.Blocks(title=title) as demo:
45
  gr.Markdown(description2)
46
  gr.Markdown("""---""")
47
 
48
-
49
- Diabetes_binary = gr.Slider(label="Diabetes_binary Score", minimum = 0, maximum = 1, value = 1, step = 1)
50
  HighBP = gr.Slider(label="BP Score", minimum = 0, maximum = 1, value = 1, step = 1)
51
  HighChol = gr.Slider(label="Cholesterol Score", minimum = 0, maximum = 1, value = 1, step = 1)
52
  CholCheck = gr.Slider(label="CholCheck Score", minimum = 0, maximum = 1, value = 1, step = 1)
@@ -77,11 +75,11 @@ with gr.Blocks(title=title) as demo:
77
 
78
  submit_btn.click(
79
  main_func,
80
- [Diabetes_binary, HighBP, HighChol, CholCheck, BMI, Smoker, Stroke, HeartDiseaseorAttack, PhysActivity, Fruits, Veggies, HvyAlcoholConsump, AnyHealthcare, NoDocbcCost, GenHlth, MentHlth, PhysHlth, DiffWalk, Sex, Age, Education, Income],
81
  [label,local_plot], api_name="Diabetes_Predictor"
82
  )
83
 
84
  gr.Markdown("### Click on any of the examples below to see how it works:")
85
- gr.Examples([[0,0,1,0,22,0,0,0,1,1,1,0,0,1,3,25,23,1,1,21,5,3], [1,1,1,1,30,1,1,1,0,0,0,1,1,0,2,20,23,0,0,21,3,2]], [Diabetes_binary, HighBP, HighChol, CholCheck, BMI, Smoker, Stroke, HeartDiseaseorAttack, PhysActivity, Fruits, Veggies, HvyAlcoholConsump, AnyHealthcare, NoDocbcCost, GenHlth, MentHlth, PhysHlth, DiffWalk, Sex, Age, Education, Income], [label,local_plot], main_func, cache_examples=True)
86
 
87
  demo.launch()
 
13
  explainer = shap.Explainer(loaded_model) # PLEASE DO NOT CHANGE THIS.
14
 
15
  # Create the main function for server
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)
 
45
  gr.Markdown(description2)
46
  gr.Markdown("""---""")
47
 
 
 
48
  HighBP = gr.Slider(label="BP Score", minimum = 0, maximum = 1, value = 1, step = 1)
49
  HighChol = gr.Slider(label="Cholesterol Score", minimum = 0, maximum = 1, value = 1, step = 1)
50
  CholCheck = gr.Slider(label="CholCheck Score", minimum = 0, maximum = 1, value = 1, step = 1)
 
75
 
76
  submit_btn.click(
77
  main_func,
78
+ [HighBP, HighChol, CholCheck, BMI, Smoker, Stroke, HeartDiseaseorAttack, PhysActivity, Fruits, Veggies, HvyAlcoholConsump, AnyHealthcare, NoDocbcCost, GenHlth, MentHlth, PhysHlth, DiffWalk, Sex, Age, Education, Income],
79
  [label,local_plot], api_name="Diabetes_Predictor"
80
  )
81
 
82
  gr.Markdown("### Click on any of the examples below to see how it works:")
83
+ gr.Examples([[0,0,1,0,22,0,0,0,1,1,1,0,0,1,3,25,23,1,1,21,5,3], [1,1,1,1,30,1,1,1,0,0,0,1,1,0,2,20,23,0,0,21,3,2]], [HighBP, HighChol, CholCheck, BMI, Smoker, Stroke, HeartDiseaseorAttack, PhysActivity, Fruits, Veggies, HvyAlcoholConsump, AnyHealthcare, NoDocbcCost, GenHlth, MentHlth, PhysHlth, DiffWalk, Sex, Age, Education, Income], [label,local_plot], main_func, cache_examples=True)
84
 
85
  demo.launch()