Inferensys

Glossary

Shapley Values

A method from cooperative game theory used in machine learning to calculate the fair contribution of each feature to a specific model prediction.
ML engineer managing model training cluster on laptop, GPU utilization visible, technical deep learning setup.
FEATURE ATTRIBUTION

What are Shapley Values?

A foundational concept from cooperative game theory adapted for machine learning to assign a fair, axiomatic importance score to each feature for a specific prediction.

Shapley values are a method from cooperative game theory that fairly distributes the payout of a coalition among its players based on their marginal contributions. In machine learning, they are adapted to decompose a single model prediction by assigning each input feature an importance value, representing its weighted average contribution across all possible feature coalitions.

The calculation satisfies four axioms: efficiency, symmetry, dummy, and additivity, ensuring a unique, fair attribution. The practical implementation, SHAP (SHapley Additive exPlanations), approximates these values to explain black-box model outputs, making them a gold standard for model explainability and algorithmic auditing.

AXIOMATIC FOUNDATIONS

Key Properties of Shapley Values

Shapley values are defined by a unique set of desirable axioms that guarantee a fair and consistent distribution of contributions. These mathematical properties are what make the solution concept both elegant in game theory and reliable for machine learning interpretability.

01

Efficiency

The sum of the Shapley values for all features equals the difference between the model's prediction for a specific instance and the average prediction over the entire dataset. This property ensures a complete and additive decomposition of the prediction, leaving no contribution unaccounted for. In practical terms, if a model predicts a loan rejection with a score of 0.8 while the baseline is 0.5, the Shapley values for income, debt, and credit history will sum to exactly 0.3.

02

Symmetry

If two features contribute identically to every possible subset of other features, they must receive identical Shapley values. This guarantees equal treatment for equal contribution, preventing any arbitrary bias in the attribution process. For example, if 'monthly_income' and 'annual_income_divided_by_12' provide the exact same predictive information in all coalitions, they will be assigned precisely the same importance score.

03

Dummy (Null Player)

A feature that contributes nothing to the prediction—regardless of which other features it is combined with—receives a Shapley value of exactly zero. This axiom ensures that irrelevant features are correctly ignored. If a model has learned to disregard a 'customer_ID' column entirely, its Shapley value will be 0.0, preventing noise features from diluting the explanation.

04

Linearity (Additivity)

If a prediction is the sum of two separate games (or models), the Shapley value for the combined game is the sum of the Shapley values from each individual game. This property allows for consistent explanations across ensemble methods. When using a Random Forest that averages 100 decision trees, the Shapley value for the ensemble is exactly the average of the Shapley values computed for each individual tree.

05

Marginalism

The Shapley value is fundamentally a weighted average of marginal contributions. It calculates the importance of a feature by observing how much the prediction changes when the feature is added to every possible subset of the other features. This exhaustive consideration of all possible feature orderings is what distinguishes Shapley values from simpler, order-dependent attribution methods and captures complex interaction effects.

SHAPLEY VALUES EXPLAINED

Frequently Asked Questions

Clear, technically precise answers to the most common questions about Shapley values in machine learning, from foundational game theory concepts to practical implementation challenges.

Shapley values are a feature attribution method that assigns each input feature a fair contribution score for a specific model prediction, derived from cooperative game theory. The method treats each feature as a 'player' in a coalition game where the 'payout' is the model's prediction. For a given instance, the Shapley value of a feature is the weighted average of its marginal contribution across all possible subsets of features. Formally, for feature i, the Shapley value φ_i is computed as:

code
φ_i = Σ_{S ⊆ N \ {i}} [|S|! (|N| - |S| - 1)! / |N|!] × [f(S ∪ {i}) - f(S)]

where N is the set of all features, S is a subset not containing i, and f(S) is the model's prediction using only features in S. This formulation satisfies four axioms: efficiency (contributions sum to the prediction difference from the average), symmetry (identical contributions yield equal values), dummy (zero-contribution features get zero value), and additivity (values combine across games). In practice, exact computation is exponential, so methods like KernelSHAP and TreeSHAP provide efficient approximations.

FEATURE ATTRIBUTION COMPARISON

Shapley Values vs. Other Attribution Methods

A technical comparison of Shapley values against other common model explanation techniques across key properties relevant to enterprise governance and auditability.

PropertyShapley ValuesLIMEIntegrated Gradients

Theoretical Foundation

Cooperative game theory (axiomatic)

Local surrogate modeling (heuristic)

Path integration of gradients (axiomatic)

Efficiency (sum to prediction)

Model Agnostic

Handles Feature Correlation

Via conditional expectation

Struggles; perturbed samples unrealistic

Requires careful baseline selection

Computational Cost

High (exponential in features)

Moderate (sampling-based)

Moderate (requires gradients)

Global Explanations

Yes (via mean absolute value)

No (local only)

Yes (via average attributions)

Consistency Guarantee

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.