Search code examples
machine-learningscikit-learnshapbeeswarm

Why are the SHAP values for some features in my model always negative (or positive)?


I am explaining a HistGradientBoostingRegressor from sci-kit learn. I use the TreeExplainer from the shap package to get the SHAP values. My model has 48 features, some of which are strongly correlated. The beeswarm summary plot of the model looks like this:

enter image description here

How is it possible that the SHAP values of some features are consistently negative (or positive) and not centered at 0?

I never saw this anywhere else. Intuitively it does not make sense to me, since the model could just add a constant to avoid the shift.


Solution

  • As is often the case, formulating the question helped to discover the answer. The problem arises because i accidentally scaled the data the model was trained on in a different way than the data i passed to the explanation algorithm.

    A similar question has been answered on github: https://github.com/slundberg/shap/issues/553