mertkarabacak commited on
Commit
32b7174
1 Parent(s): 1e532ae

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -163,15 +163,16 @@ def y1_interpret_xgb(*args):
163
  df = pd.DataFrame([args], columns=x1.columns)
164
  df = df.astype({col: "category" for col in categorical_columns1})
165
  shap_values = y1_explainer_xgb.shap_values(xgb.DMatrix(df, enable_categorical=True))
166
- scores_desc = list(zip(shap_values[0], x1.columns))
167
- scores_desc = sorted(scores_desc)
168
- fig_m = plt.figure(facecolor='white')
169
- fig_m.set_size_inches(14, 24)
170
- plt.barh([s[1] for s in scores_desc], [s[0] for s in scores_desc])
171
- plt.title("Feature Shap Values", fontsize = 24, pad = 20, fontweight = 'bold')
172
- plt.yticks(fontsize=12)
173
- plt.xlabel("Shap Value", fontsize = 16, labelpad=8, fontweight = 'bold')
174
- plt.ylabel("Feature", fontsize = 16, labelpad=14, fontweight = 'bold')
 
175
  return fig_m
176
 
177
  def y1_interpret_lgb(*args):
@@ -427,11 +428,11 @@ with gr.Blocks(title = "NTDB-Epidural") as demo:
427
  with gr.Row():
428
 
429
  gr.Markdown(
430
- """
431
  <br/>
 
432
  ## Mortality
433
- <br/>
434
  """
 
435
  )
436
 
437
  with gr.Row():
 
163
  df = pd.DataFrame([args], columns=x1.columns)
164
  df = df.astype({col: "category" for col in categorical_columns1})
165
  shap_values = y1_explainer_xgb.shap_values(xgb.DMatrix(df, enable_categorical=True))
166
+ shap.plots.bar(shap_values[0])
167
+ fig_m = plt.gcf()
168
+ ax = plt.gca()
169
+ fig_m.set_figheight(12)
170
+ fig_m.set_figwidth(5)
171
+ plt.xlabel("Mean |SHAP Value|", fontsize =12, fontweight = 'heavy', labelpad = 8)
172
+ plt.tick_params(axis="y",direction="out", labelsize = 12)
173
+ plt.tick_params(axis="x",direction="out", labelsize = 12)
174
+ wrap_labels(ax, 30)
175
+ ax.figure
176
  return fig_m
177
 
178
  def y1_interpret_lgb(*args):
 
428
  with gr.Row():
429
 
430
  gr.Markdown(
 
431
  <br/>
432
+ """
433
  ## Mortality
 
434
  """
435
+ <br/>
436
  )
437
 
438
  with gr.Row():