Inferensys

Glossary

Shapley Values

A concept from cooperative game theory that fairly distributes the 'payout' (the prediction) among the 'players' (the features) by considering the average marginal contribution of a feature across all possible coalitions of features.
Data engineer managing feature store on laptop, feature definitions visible, casual data engineering session.
COOPERATIVE GAME THEORY

What is Shapley Values?

A foundational concept in cooperative game theory used to fairly distribute a collective outcome among contributing players based on their average marginal contribution across all possible coalitions.

Shapley Values are a solution concept that assigns a unique, fair payout to each player in a cooperative game by calculating the weighted average of their marginal contribution to every possible coalition they could join. The method exhaustively considers all permutations of players, measuring how much the total payoff changes when a specific player is added to a subset, ensuring the final attribution satisfies axioms of efficiency, symmetry, dummy, and additivity.

In explainable fraud detection, Shapley Values form the mathematical backbone of SHAP, where the 'game' is the prediction task, the 'players' are the input features, and the 'payout' is the model's anomaly score. This provides a theoretically rigorous method to decompose a transaction's risk score, showing precisely how much each feature—such as transaction velocity or device fingerprint—contributed to pushing the prediction away from the average, enabling auditors to validate blocking decisions.

AXIOMATIC FOUNDATIONS

Key Properties of Shapley Values

Shapley Values are the only feature attribution method that uniquely satisfies four fundamental axioms from cooperative game theory, ensuring a mathematically fair and consistent distribution of a model's prediction among its input features.

01

Efficiency (Local Accuracy)

The sum of all feature attributions equals the difference between the model's prediction for a specific instance and the average prediction. This property guarantees completeness—the explanation accounts for the entire prediction output, leaving no residual unexplained variance.

  • Additive property: f(x) = ϕ₀ + Σ ϕᵢ where ϕ₀ is the base value and ϕᵢ are Shapley values
  • Ensures the explanation is a true decomposition of the prediction
  • Critical for regulatory compliance where full accountability is required
02

Symmetry (Fairness)

If two features contribute identically to every possible coalition, they receive identical Shapley values. This equal treatment property prevents bias in attribution and ensures that features with the same predictive influence are assigned the same importance.

  • Eliminates arbitrary ordering effects present in simpler methods
  • Guarantees consistent ranking of feature importance
  • Essential for auditing models in lending and hiring where fairness is legally mandated
03

Dummy (Null Player)

A feature that contributes nothing to the prediction—regardless of which other features are present—receives a Shapley value of exactly zero. This null effect property ensures that irrelevant features do not receive spurious attribution.

  • Automatically zeroes out non-predictive variables
  • Prevents misleading explanations that highlight noise features
  • Useful for feature selection by identifying truly inert inputs
04

Additivity (Linearity)

If a prediction is the sum of two separate model outputs, the Shapley value for a feature is the sum of its Shapley values from each model. This linear consistency property enables explanations for ensemble models like random forests and gradient boosted trees.

  • Allows decomposition of ensemble predictions into component model contributions
  • Ensures explanations remain consistent when models are combined
  • Foundational for SHAP's ability to explain any model architecture
05

Marginal Contribution Calculation

Shapley values compute a feature's importance by averaging its marginal contribution across all 2ᴺ possible feature coalitions. For each subset of features, the model's prediction is evaluated with and without the target feature, and the difference is weighted by coalition size.

  • Weighting formula: |S|!(n - |S| - 1)! / n! where S is the coalition
  • Accounts for feature interactions by considering all possible orderings
  • Computationally expensive—exact calculation requires O(2ⁿ) model evaluations
06

Uniqueness Guarantee

Shapley values are the only attribution method that simultaneously satisfies efficiency, symmetry, dummy, and additivity. This uniqueness theorem, proven by Lloyd Shapley in 1953, provides the theoretical foundation for why SHAP is the gold standard in model explainability.

  • No other method can claim this axiomatic completeness
  • Provides a defensible mathematical basis for regulatory submissions
  • Contrasts with heuristic methods like LIME that lack formal guarantees
SHAPLEY VALUES EXPLAINED

Frequently Asked Questions

Clear, concise answers to the most common questions about Shapley values and their application in machine learning explainability and fraud detection.

Shapley values are a game-theoretic solution concept that fairly distributes the total payout of a cooperative game among its players based on their average marginal contribution across all possible coalitions. In machine learning, the 'game' is the prediction task, the 'players' are the input features, and the 'payout' is the difference between the model's prediction for a specific instance and the average prediction. A Shapley value for a feature is computed by evaluating the model's prediction with and without that feature, averaged over all possible subsets of other features. This exhaustive consideration of feature interactions ensures the attribution satisfies four axioms: efficiency (contributions sum to the prediction difference), symmetry (identical contributions yield equal values), dummy (zero-contribution features get zero value), and additivity (values combine across games). The computational complexity is exponential—requiring 2^N model evaluations for N features—which is why practical implementations like SHAP use approximation methods such as kernel-based sampling or TreeSHAP for tree-based models.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.