SHAP (SHapley Additive exPlanations) explains one prediction by assigning part of its value to each input feature. It is a model-agnostic, local explainability method: rather than describing a model’s behavior everywhere, it asks why this particular example received this prediction. A feature’s attribution reflects how much it contributes relative to a baseline prediction. section 9.4.2 section 9.0
Its intuition comes from cooperative game theory. If a team earns a prize, each person’s fair share should account for what they add to every possible group they could join. SHAP treats features as team members and the prediction as the prize: a Shapley value averages a feature’s added contribution across feature coalitions. The resulting attributions divide the prediction’s change from its base value among the features. section 9.4.2 section 9.6
Figure 9.17 Computing the Shapley values for Dev. The top row is all the coalitions with Dev. The middle row shows the corresponding coalitions without Dev. The last row shows the individual weighted differences in the values of the coalitions. Summing across the last row gives us the Shapley values for Dev: φDev = 6.
Compare each coalition with and without Dev, weight the change in coalition value, and sum those changes to obtain one Shapley value. The same accounting is used to assign a prediction’s feature attributions. section 9.4.2
A practical SHAP explanation follows this pattern:
- Choose the individual prediction to explain and a base or average prediction for comparison. section 9.4.2 section 9.4.2
- Measure each feature’s contribution across possible feature combinations rather than crediting it from only one ordering. section 9.4.2
- Assign positive values to features that push the prediction above the base value and negative values to those that push it downward. section 9.4.2
- Check that the feature contributions add to the explained prediction; this additivity also supports aggregation in ensembles. section 9.6
Explaining an XGBoost prediction
A TreeSHAP explainer can evaluate one held-out XGBoost example and return its feature attributions. A waterfall plot pairs the example’s feature values with their Shapley values. A force plot instead shows the prediction moving from the average value of -0.194 to 0.52: right-pointing features raise it, while left-pointing features pull it back toward the base value. section 9.4.2 section 9.4.2 section 9.4.2
Direct Shapley-value computation becomes infeasible for real-world data with many features and examples because it considers all feature combinations. SHAP uses a local surrogate approach to approximate these values, while TreeSHAP is a specialized variant for tree-based models. SHAP and LIME both explain local predictions, but SHAP bases feature credit on Shapley values; neither method is fundamentally designed to evaluate feature interactions. section 9.6 section 9.6 section 9.6




