thov commited on
Commit
48b4eec
1 Parent(s): e603fcd

fix bug on shap values for numerical values

Browse files
Files changed (1) hide show
  1. autoML.py +13 -8
autoML.py CHANGED
@@ -92,9 +92,10 @@ def autoML(csv, task, budget, label, metric_to_minimize_class, metric_to_minimiz
92
 
93
  tab1, tab2, tab3, tab4 = st.tabs(["AutoML", "Best Model", "Partial Dependence", "Shap Values"])
94
 
 
95
  with tab1:
96
 
97
- time_history, best_valid_loss_history, valid_loss_history, config_history, metric_history = get_output_from_log(filename=log, time_budget=120)
98
 
99
  def model(s):
100
  mod = s.get('Current Learner')
@@ -132,6 +133,7 @@ def autoML(csv, task, budget, label, metric_to_minimize_class, metric_to_minimiz
132
  st.write('Estimator tested')
133
  st.table(automl.estimator_list)
134
 
 
135
  with tab2:
136
  st.header('Best Model')
137
 
@@ -171,6 +173,7 @@ def autoML(csv, task, budget, label, metric_to_minimize_class, metric_to_minimiz
171
 
172
  download_model(automl)
173
 
 
174
  with tab3:
175
  with st.container():
176
  st.subheader('1D Partial Dependance for the three most important features')
@@ -242,13 +245,15 @@ def autoML(csv, task, budget, label, metric_to_minimize_class, metric_to_minimiz
242
 
243
  df_features_test = df_test[df_test.columns.difference([label])]
244
 
245
- with st.spinner(f'Compute Shap Values'):
246
- explainer = shap.Explainer(pipeline.predict, df_features_test)
247
- shap_values = explainer(df_features_test)
248
-
249
- st.set_option('deprecation.showPyplotGlobalUse', False)
250
- st.pyplot(shap.plots.beeswarm(shap_values))
251
- st.pyplot(shap.summary_plot(shap_values, plot_type='violin'))
 
 
252
 
253
 
254
 
 
92
 
93
  tab1, tab2, tab3, tab4 = st.tabs(["AutoML", "Best Model", "Partial Dependence", "Shap Values"])
94
 
95
+
96
  with tab1:
97
 
98
+ time_history, best_valid_loss_history, _, config_history, _ = get_output_from_log(filename=log, time_budget=120)
99
 
100
  def model(s):
101
  mod = s.get('Current Learner')
 
133
  st.write('Estimator tested')
134
  st.table(automl.estimator_list)
135
 
136
+
137
  with tab2:
138
  st.header('Best Model')
139
 
 
173
 
174
  download_model(automl)
175
 
176
+
177
  with tab3:
178
  with st.container():
179
  st.subheader('1D Partial Dependance for the three most important features')
 
245
 
246
  df_features_test = df_test[df_test.columns.difference([label])]
247
 
248
+ with st.container():
249
+ with st.spinner(f'Compute Shap Values...'):
250
+ explainer = shap.Explainer(pipeline.predict, df_features_test)
251
+ shap_values = explainer(df_features_test)
252
+ st.subheader('Beeswarm Plot')
253
+ plt.figure()
254
+ st.pyplot(shap.plots.beeswarm(shap_values, show=False).figure)
255
+ #st.divider()
256
+ #st.pyplot(shap.plots.violin(shap_values, show=False).figure)
257
 
258
 
259