NellCoriander commited on
Commit
a1007e8
·
1 Parent(s): fe0ee03

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -17
app.py CHANGED
@@ -37,7 +37,7 @@ def main_func(age,sex,cp,trtbps,chol,fbs,restecg,thalachh,exng,oldpeak,slp,caa,t
37
  return {"High Risk": float(prob[0][1]), "Low Risk": 1-float(prob[0][1])}, local_plot
38
 
39
  # Create the UI
40
- title = "**Heart Attack Demo App** 🪐"
41
  description1 = """
42
  This app takes six inputs about employees' satisfaction with different aspects of their work (such as work-life balance, ...) and predicts whether the employee intends to stay with the employer or leave. There are two outputs from the app: 1- the predicted probability of stay or leave, 2- Shapley's force-plot which visualizes the extent to which each factor impacts the stay/ leave prediction.✨
43
  """
@@ -53,23 +53,25 @@ with gr.Blocks(title=title) as demo:
53
  gr.Markdown("""---""")
54
  gr.Markdown(description2)
55
  gr.Markdown("""---""")
56
- age = gr.Number(label="Age Score", value=40)
57
- sex = gr.Dropdown(["Male", "Female"], label="Gender")
58
- cp = gr.Slider(minimum=1, maximum=4, default=1, step=1, label="Chest Pain Type")
59
- trtbps = gr.Slider(minimum=50, maximum=200, default=120, step=1, label="Resting Blood Pressure (in mm Hg)")
60
- chol = gr.Slider(minimum=80, maximum=500, default=190, step=1, label="Cholesterol Level (mg/dL)")
61
- fbs = gr.Slider(minimum=0, maximum=1, default=0, step=.1, label="(fasting blood sugar > 120 mg/dl) (1 = true; 0 = false)")
62
- restecg = gr.Slider(minimum=0, maximum=200, step=1, default=80, label="resting electrocardiographic results")
63
- thalachh = gr.Slider(minimum=80, maximum=400, step=1, default=200, label="maximum heart rate achieved")
64
- exng = gr.Slider(minimum=80, maximum=400, step=1, default=200, label="maximum heart rate achieved")
65
- oldpeak = gr.Slider(minimum=0, maximum=10, step=.1, default=1, label="ST depression induced by exercise relative to rest")
66
- slp = gr.Slider(minimum=0, maximum=2, step=.1, default=1, label="speech-language pathologist")
67
- caa = gr.Slider(minimum=0, maximum=4, step=.1, default=2, label="cerebral amyloid angiopathy")
68
- thall = gr.Slider(minimum=0, maximum=3, default=2, step=.1, label="thallium stress test")
69
-
70
- submit_btn = gr.Button("Process")
 
 
71
 
72
- with gr.Column(visible=True) as output_col:
73
  label = gr.Label(label = "Predicted Label")
74
  local_plot = gr.Plot(label = 'Shap:')
75
 
 
37
  return {"High Risk": float(prob[0][1]), "Low Risk": 1-float(prob[0][1])}, local_plot
38
 
39
  # Create the UI
40
+ title = "**Heart Attack Demo App** 🫀"
41
  description1 = """
42
  This app takes six inputs about employees' satisfaction with different aspects of their work (such as work-life balance, ...) and predicts whether the employee intends to stay with the employer or leave. There are two outputs from the app: 1- the predicted probability of stay or leave, 2- Shapley's force-plot which visualizes the extent to which each factor impacts the stay/ leave prediction.✨
43
  """
 
53
  gr.Markdown("""---""")
54
  gr.Markdown(description2)
55
  gr.Markdown("""---""")
56
+ with gr.Row():
57
+ with gr.Column():
58
+ age = gr.Number(label="Age Score", value=40)
59
+ sex = gr.Dropdown(["Male", "Female"], label="Gender")
60
+ cp = gr.Slider(minimum=1, maximum=4, default=1, step=1, label="Chest Pain Type")
61
+ trtbps = gr.Slider(minimum=50, maximum=200, default=120, step=1, label="Resting Blood Pressure (in mm Hg)")
62
+ chol = gr.Slider(minimum=80, maximum=500, default=190, step=1, label="Cholesterol Level (mg/dL)")
63
+ fbs = gr.Slider(minimum=0, maximum=1, default=0, step=.1, label="(fasting blood sugar > 120 mg/dl) (1 = true; 0 = false)")
64
+ restecg = gr.Slider(minimum=0, maximum=200, step=1, default=80, label="resting electrocardiographic results")
65
+ with gr.Column():
66
+ thalachh = gr.Slider(minimum=80, maximum=400, step=1, default=200, label="maximum heart rate achieved")
67
+ exng = gr.Slider(minimum=80, maximum=400, step=1, default=200, label="maximum heart rate achieved")
68
+ oldpeak = gr.Slider(minimum=0, maximum=10, step=.1, default=1, label="ST depression induced by exercise relative to rest")
69
+ slp = gr.Slider(minimum=0, maximum=2, step=.1, default=1, label="speech-language pathologist")
70
+ caa = gr.Slider(minimum=0, maximum=4, step=.1, default=2, label="cerebral amyloid angiopathy")
71
+ thall = gr.Slider(minimum=0, maximum=3, default=2, step=.1, label="thallium stress test")
72
+ submit_btn = gr.Button("Process")
73
 
74
+ with gr.Row(visible=True) as output_col:
75
  label = gr.Label(label = "Predicted Label")
76
  local_plot = gr.Plot(label = 'Shap:')
77