Inferensys

Glossary

SHAP

SHAP (SHapley Additive exPlanations) is a unified framework for interpreting model predictions by assigning each feature an importance value for a particular prediction based on Shapley values from cooperative game theory.
Governance lead reviewing model governance framework on laptop, policy documents visible, executive office setup.
SHAPLEY ADDITIVE EXPLANATIONS

What is SHAP?

SHAP is a unified framework for interpreting model predictions by assigning each input feature an importance value for a particular prediction, grounded in Shapley values from cooperative game theory.

SHAP (SHapley Additive exPlanations) is a game-theoretic approach to explain the output of any machine learning model. It connects optimal credit allocation with local explanations by computing Shapley values, which represent the average marginal contribution of a feature across all possible feature coalitions. This ensures a fair, axiomatically-grounded distribution of the prediction among the input features.

In medical imaging, SHAP provides pixel-level or region-level feature attribution that satisfies key properties: local accuracy, missingness, and consistency. Unlike simpler gradient-based methods, SHAP guarantees that the sum of all feature contributions equals the model's prediction difference from a baseline, making it a faithful and auditable tool for regulatory explainability in diagnostic AI systems.

Unified Attribution Framework

Key Properties of SHAP

SHapley Additive exPlanations provide a theoretically grounded method for assigning each input feature an importance value for a specific prediction, ensuring consistency and local accuracy in model interpretation.

01

Additive Feature Attribution

SHAP explains a prediction as a sum of individual feature contributions. The model's output is decomposed into a base value (the average prediction) plus the additive Shapley value for each feature.

  • Linear Decomposition: The final prediction equals the sum of all feature attributions plus a constant base value.
  • Local Accuracy: The explanation perfectly matches the original model output for the specific instance being explained.
  • Contrastive: Each value represents the change in prediction when conditioning on that feature, relative to the average.
02

Shapley Value Foundations

SHAP is rooted in cooperative game theory, where each feature is a 'player' in a coalition. The Shapley value is the unique solution that satisfies four axioms of fair profit distribution.

  • Efficiency: The sum of all contributions equals the total prediction minus the average.
  • Symmetry: Features that contribute identically receive identical values.
  • Dummy: A feature that never changes the prediction receives a value of zero.
  • Additivity: For ensemble models, the SHAP value of the ensemble is the average of individual model SHAP values.
03

KernelSHAP: Model-Agnostic Estimation

KernelSHAP is a model-agnostic method that estimates Shapley values using a specially weighted linear regression. It treats the model as a black box, requiring only the ability to evaluate the model on different input subsets.

  • Weighting Kernel: Uses the Shapley kernel to weight coalitions, giving higher importance to small and large coalitions.
  • Sampling Strategy: Approximates the exponential number of coalitions by sampling, trading computational cost for estimation accuracy.
  • Background Dataset: Requires a representative sample of data to serve as the baseline for missing feature values during coalition evaluation.
04

TreeSHAP: Exact Computation for Trees

TreeSHAP computes exact Shapley values for tree-based models in polynomial time, avoiding the exponential complexity of naive calculation. It leverages the internal structure of decision trees for precise, fast attribution.

  • Algorithm Complexity: Runs in O(TLD²) time where T is trees, L is leaves, and D is depth, making it feasible for large ensembles like XGBoost and LightGBM.
  • Feature Interactions: Directly captures pairwise interaction effects, decomposing predictions into main effects and interaction terms.
  • No Sampling Error: Unlike KernelSHAP, TreeSHAP yields deterministic, exact values without approximation noise.
05

DeepSHAP: High-Speed Neural Network Approximation

DeepSHAP combines DeepLIFT's backpropagation rules with Shapley value principles to efficiently approximate SHAP values for deep learning models. It linearizes network components to propagate attributions rapidly.

  • Linear Composition: Treats common operations like ReLU, max-pooling, and convolutions as linearizable components.
  • Reference Values: Uses a background sample to define the 'off' state for each neuron, analogous to the baseline in Integrated Gradients.
  • Speed Advantage: Orders of magnitude faster than KernelSHAP for deep networks, enabling practical use on large medical imaging models.
06

Consistency and Uniqueness

SHAP is the only additive feature attribution method that satisfies the consistency property: if a model changes so that a feature's marginal contribution increases or stays the same, that feature's attributed importance should not decrease.

  • Theoretical Uniqueness: Proven to be the unique solution within the additive attribution class that satisfies local accuracy, missingness, and consistency.
  • Comparison to Other Methods: Unlike LIME, which uses a heuristic kernel, SHAP's weighting is theoretically justified. Unlike simple gradients, SHAP satisfies completeness.
  • Regulatory Alignment: This theoretical grounding makes SHAP particularly suitable for regulatory submissions where explanation fidelity must be demonstrable.
FEATURE ATTRIBUTION COMPARISON

SHAP vs. Other Attribution Methods

A technical comparison of SHAP against other prominent post-hoc explainability methods for medical imaging diagnostic models, evaluating properties critical for regulatory compliance and clinical trust.

PropertySHAPGrad-CAMIntegrated Gradients

Theoretical Foundation

Cooperative game theory (Shapley values)

Gradient-weighted class activation mapping

Path-integrated gradients from baseline

Completeness Axiom Satisfied

Model-Agnostic

Local Accuracy Guarantee

Computational Cost

High (exponential in features)

Low (single backward pass)

Medium (50-200 integration steps)

Spatial Resolution of Output

Per-pixel or per-superpixel

Coarse (14x14 to 28x28 grid)

Per-pixel

Regulatory Suitability (FDA/MDR)

High (axiomatic guarantees)

Low (no completeness guarantee)

Medium (baseline-dependent)

Native 3D Volumetric Support

UNDERSTANDING SHAP

Frequently Asked Questions

Clear, technically precise answers to the most common questions about SHapley Additive exPlanations and their application in medical imaging diagnostics.

SHAP (SHapley Additive exPlanations) is a unified framework for interpreting machine learning model predictions by assigning each input feature an importance value for a specific prediction. It is grounded in cooperative game theory, specifically Shapley values, which fairly distribute a payout among players based on their marginal contributions to the total. In the context of a model, the 'game' is the prediction task, the 'players' are the input features, and the 'payout' is the difference between the actual prediction and the average prediction. SHAP computes the Shapley value for each feature by averaging its marginal contribution over all possible subsets of other features. This ensures the attribution satisfies key properties: local accuracy (the sum of attributions equals the prediction difference), missingness (absent features get zero attribution), and consistency (if a feature's contribution increases, its attribution doesn't decrease). For medical imaging, this means a SHAP analysis of a chest X-ray classifier can decompose a 'pneumonia' prediction into pixel-level contributions, showing exactly which regions of the lung drove the diagnosis and which were irrelevant.

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.