3

I've been trying to convert shap values with the logit link to probabilities for all my features in a dataset. The model_output ='probability' parameter doesn't work for my catboost model. I want to convert the shap values for each feature so that when you sum them they equal the probability shown on the force plot. I've used a prewritten function to convert log odds to probabilities but the sum doesn't equal the same in the force plot. Any suggestions?

explainer = shap.TreeExplainer(catboost)
shap_values = explainer.shap_values(df_X_test)
shap.force_plot(explainer.expected_value, shap_values[0,:], df_X_test.iloc[0,:],link='logit')

1 Answers1

1

A workaround I have been using for instance-level explanations:

shap_values = (shap_values / sum(shap_values)) * probability

Where shap_values is a list, len(shap_values) = n_features, one Shapley value per feature and the probability is a double in [0, 1].

This will scale your Shapley values from whatever domain they are in, to the predicted probability.

Flair
  • 2,609
  • 1
  • 29
  • 41
StefanPopov
  • 11
  • 1
  • 3