Course contentsShow
← Machine Learning and Deep Learning
Lesson 3205 of 3,53870. Interpretability: Feature-Based MethodsFree lesson

Introduction to SHAP and Shapley Values

Understand SHAP's foundation in cooperative game theory and how Shapley values ensure fair feature attribution.

Introduction to SHAP and Shapley Values

You'll learn how SHAP brings fairness from game theory to explain individual predictions.

The Core Idea

Imagine four friends collaborating on a startup. When it succeeds, how do you fairly divide the profit among them? Some contributed code, others marketing, some both. Shapley values solve this by considering every possible team combination and measuring each person's marginal contribution.

SHAP (SHapley Additive exPlanations) applies this same fairness principle to machine learning. For any prediction, it asks: "How much did each feature contribute to moving the prediction away from the baseline?" Just as we'd evaluate each friend's contribution by seeing how teams perform with and without them, SHAP evaluates each feature by computing predictions across all possible feature combinations.

Why Cooperative Game Theory?

In cooperative game theory, Shapley values satisfy three fairness axioms:

  1. Symmetry: If two features contribute equally, they get equal credit
  2. Dummy: Features that don't change predictions get zero credit
  3. Additivity: Contributions sum to the total prediction difference from baseline

Unlike permutation importance (which you just learned), which measures global feature importance by random shuffling, SHAP provides local explanations—showing exactly how features influenced this specific prediction.

The Foundation

The Shapley value for feature i averages its marginal contribution across all possible subsets of other features. This ensures no feature gets unfairly credited or blamed due to evaluation order or feature interactions.

Key Takeaway: SHAP uses Shapley values from game theory to fairly distribute prediction "credit" among features, ensuring consistent and mathematically principled local explanations for individual predictions.