saad177 commited on
Commit
9637b10
1 Parent(s): 2ee2174
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -115,7 +115,13 @@ with gr.Blocks() as demo:
115
  explainer = shap.Explainer(rf_model)
116
  shap_values = explainer.shap_values(df)[1] # Select SHAP values for class 1
117
  print(shap_values.shape) # should show (1, 4)
118
- shap_waterfall_plot = shap.plots.waterfall(shap_values[0])
 
 
 
 
 
 
119
 
120
  ## save user's data in hopsworks
121
  if consent_input == True:
 
115
  explainer = shap.Explainer(rf_model)
116
  shap_values = explainer.shap_values(df)[1] # Select SHAP values for class 1
117
  print(shap_values.shape) # should show (1, 4)
118
+ # Convert shap_values to Explanation object
119
+ shap_values_exp = shap.Explanation(
120
+ values=shap_values[0], base_values=explainer.expected_value[1]
121
+ )
122
+
123
+ # Plot the waterfall plot
124
+ shap_waterfall_plot = shap.plots.waterfall(shap_values_exp)
125
 
126
  ## save user's data in hopsworks
127
  if consent_input == True: