---
title: Shapley Value in Machine Learning
url: https://www.emergentmind.com/topics/shapley-value-in-machine-learning
type: topic
---

# Shapley Value in Machine Learning

The Shapley value, originating in cooperative game theory, has become a foundational tool for attributing value to elements—such as data points, features, or models—in a variety of machine learning (ML) settings. Building upon rigorous axiomatic foundations, the Shapley value supplies a unique allocation scheme satisfying fairness properties (efficiency, symmetry, null-player, additivity) and forms the backbone of numerous algorithms for data valuation, model explainability, and resource sharing in ML workflows. This article delineates the mathematical formalism, computational strategies, application domains, and recent innovations—including order-sensitive extensions and scalable estimation—of the Shapley value in machine learning.

## 1. Shapley Value: Formal Definition and Axiomatic Foundations

In the canonical setup, let $N = \{1, \ldots, n\}$ denote the collection of "players" (which may be data points, features, models, or agents), and $v: 2^N \rightarrow \mathbb{R}$ a characteristic or utility function satisfying $v(\emptyset) = 0$. The Shapley value attributed to player $i$ is defined as

\[
\phi_i(v) = \sum_{S \subseteq N \setminus \{i\}} \frac{|S|!\,(n-|S|-1)!}{n!} (v(S \cup \{i\}) - v(S)).
\]

An equivalent permutation-based form is

\[
\phi_i(v) = \frac{1}{n!} \sum_{\pi \in S_n} (v(P_i^\pi \cup \{i\}) - v(P_i^\pi)),
\]

where $P_i^\pi$ is the set of players preceding $i$ in permutation $\pi$. This scoring procedure uniquely satisfies the following four axioms:

- **Efficiency**: $\sum_{i} \phi_i(v) = v(N)$ (total value is distributed)
- **Symmetry**: If $v(S \cup \{i\}) = v(S \cup \{j\})$ for all $S \subseteq N \setminus \{i, j\}$, then $\phi_i(v) = \phi_j(v)$
- **Null-player**: If $v(S \cup \{i\}) = v(S)$ for all $S$, then $\phi_i(v) = 0$
- **Additivity**: For any $v, w$, $\phi_i(v + w) = \phi_i(v) + \phi_i(w)$

These axioms guarantee that the Shapley value is the fair and linear attribution scheme for cooperative scenarios, with applications in ML including model attribution, data valuation, and ensemble evaluation [2202.05594].

## 2. Core Machine Learning Applications

The Shapley value's axiomatic attributes directly enable several central ML applications:

- **Feature Selection and Attribution:** Features are the players; $v(S)$ is model performance using only subset $S$.
- **Model Explainability (SHAP):** Each feature or feature-value is separately attributed for a given prediction. The SHAP family of methods operationalizes this using weighted regression schemes (KernelSHAP) to efficiently estimate attribution at a local or global level [2410.01917, 2508.12947].
- **Data Valuation:** Each training data point is a player; $v(S)$ is performance (accuracy, loss, AUC) on a validation set when the model is trained on $S$. Data Shapley ranks, prices, or selects examples for denoising, acquisition, or market design [2202.05594, 2110.14049, 2306.07171].
- **Ensemble Member Valuation:** Individual models in ensembles are players; $v(S)$ is ensemble accuracy for subset $S$, supporting methods for ensemble pruning or adversarial detection [2101.02153].
- **Multi-agent Reinforcement Learning:** Agents are players; $v(S)$ is the global reward for subset $S$ acting. Shapley credit assignment mediates decentralized policy learning.
- **Model-Independent Variable Importance:** Using dependence measures (e.g., distance correlation, HSIC) in the value function, "Sunnies" attribute non-model-specific variable importance for exploratory analysis [2007.06011].

## 3. Computational Techniques and Scalability

Exact computation of Shapley values requires evaluating $2^n$ subsets or $n!$ permutations, impractical for $n \gtrsim 30$. The field has developed a range of approximate algorithms:

- **Monte Carlo Permutation Sampling:** Draw random permutations, compute marginal contributions in insertion order, average [2202.05594, 2311.05346]. Hoeffding and Chebyshev bounds give error guarantees.
- **KernelSHAP Weighted Regression:** Solve a constrained least-squares regression to fit Shapley values to linearized coalition outputs, using kernel-based importance weighting [2410.01917, 2508.12947].
- **Leverage Score Sampling:** Provably accurate and efficient alternative, requiring $O(n\log n)$ model evaluations, guarantees with high probability that sampled normal equations yield $(1+\epsilon)$-approximate Shapley values [2410.01917].
- **Delta-Shapley and Diminishing Marginals:** Exploiting the $O(1/k)$ decay of marginal contributions (coalition size $k$), algorithms restrict sampling to medium-sized coalitions, reducing cost by up to one order of magnitude with negligible rank-order loss [2311.05346, 2206.00511].
- **Coalitional and Partial Ordinal Values:** Modify the sampling or weighting to account for coalitions of logically-dependent features [2103.13342], or to respect the order in which players "join" (curriculum-learning, recommendation order) via Partial Ordinal Shapley Value (POSV) and order-aware permutation strategies [2305.01660].
- **Efficient Closed-Form Solutions:** For certain models (e.g., Naive Bayes with additive log-odds, or regression with Gaussian data), analytic integration yields exact or tight-bounded forms for Shapley values, further reducing computational load [2307.16718, 2007.01357].

| Method         | Complexity   | Use Case                   | Error Bounds        |
|----------------|-------------|----------------------------|--------------------|
| Permutation MC | $O(kn)$     | General, small/medium $n$  | Hoeffding           |
| KernelSHAP     | $O(n\log n)$| Local model explainability | CLT, empirical      |
| Leverage SHAP  | $O(n\log n)$| Provable global accuracy   | Matrix Chernoff     |
| Delta-Shapley  | $O((B_U-B_L)T)$| Data valuation       | Stability/SGD-based |
| Analytic       | $O(d)$      | Special model classes      | Exact or bounded    |

## 4. Extensions, Generalizations, and Variants

Recent work has expanded the Shapley value concept to address modern ML use cases:

- **Order-Sensitive and Partial Ordinal Schemes:** To account for the sequential utility of data in order-sensitive ML pipelines (curriculum learning, federated learning with ordered clients), the Partial Ordinal Shapley Value (POSV) replaces classic set-based symmetry with group-theoretic axioms over ordered tuples, with order-based marginal contributions [2305.01660]. Sampling strategies (TMC, CMC, CTMC) deliver scalable, provably unbiased POSV estimates, with error bounds and efficient approximations for class-structured problems.
- **Probabilistic Classifier Adaptation:** For probability-calibrated models, the classical binary-accuracy value function is replaced with a calibration-sensitive function using activation ($AF$) on correctness-confidence pairs; the resulting "P-Shapley" gives more discriminative data valuations [2306.07171].
- **Beta Shapley and Semivalues:** By relaxing the efficiency axiom and explicitly re-weighting coalition sizes, Beta Shapley and generalized semivalue frameworks reduce estimation variance and adapt the attribution to signal-rich coalition regimes [2110.14049].
- **Distributional and Probabilistic Shapley:** Extending to settings in which data is drawn from a distribution, the distributional Shapley value and its efficient analytic solutions allow out-of-sample valuation, stability under dataset perturbations, and principled decomposition into expected value and variance under stochastic sampling [2002.12334, 2007.01357, 2601.14543].
- **Class-Wise Valuation:** CS-Shapley introduces a value function separable with respect to in-class and out-of-class dev-set accuracy, fundamentally enhancing the detection of mislabeled or harmful examples in supervised classification [2211.06800].
- **Differentially Private Valuation:** Layered Shapley algorithms stratify sampling by coalition size and, using bounded marginal gains, support differentially private value queries with additive Laplace noise [2206.00511].
- **Fairness under Approximation:** Probably Approximate Shapley Fairness formalizes fidelity of approximate solutions, quantifying the probability and magnitude of fairness violations under stochastic or budgeted computation, and supplies a greedy active estimation (GAE) algorithm optimizing fidelity under a fixed budget [2212.00630].

## 5. Empirical Performance and Diagnostics

Multiple studies have established the practical competitiveness of Shapley value methods, across regression, classification, ensemble construction, and exploratory analysis:

- **Data Valuation**: Removal/retention experiments show that removing high-Shapley-valued examples first maximally reduces accuracy, while adding low-valued examples slows recovery [2311.05346, 2211.06800].
- **Noisy Label Detection**: Shapley-based rankings outperform leave-one-out and uncertainty-baseline methods in identifying label noise, particularly in Beta Shapley, CS-Shapley, and P-Shapley settings [2110.14049, 2211.06800, 2306.07171].
- **Ensemble Pruning and Adversarial Detection**: Attribution via Troupe or model-valuation Shapley discriminates weak, redundant, or adversarial models, rationalizes pruning, or guides reward splitting in collaborative ML [2101.02153].
- **Interpretability and Faithfulness**: Comparative studies versus heuristic alternatives (e.g., Weight of Evidence, KernelSHAP, TreeSHAP) demonstrate that analytic or coalitional Shapley approaches maintain consistency, avoid double-counting, and align closely with human-inferable attributions [2307.16718, 2103.13342].
- **Model Diagnostics and Sensitivity Analysis**: Model-independent schemes ("Sunnies") reveal non-linear dependence structure among features, identifying discrepancies between data-driven and model-driven attributions [2007.06011].

## 6. Limitations, Open Problems, and Future Directions

Despite its rigorous foundations and growing toolbox of computational methods, several challenges and open questions remain:

- **Computational Tractability**: Even with variance reduction and importance sampling, full coalition enumeration is infeasible for high-dimensional feature spaces or large datasets. Ongoing research addresses further sample complexity reductions, surrogate/influence-based proxies, or architectures with analytic collapse [2202.05594, 2307.16718].
- **Robustness of Axioms Under Approximation**: Approximate solutions may violate symmetry or efficiency, especially under tight computational budgets or for high-variance data; formalizing and controlling the probability of fairness violations is an active area [2212.00630].
- **Choice of Value Function**: Shapley attributions are only as interpretable as the coalition utility function; design must reflect intended notion of value, such as order, class-structure, or dependence, and avoid artifacts in metric selection.
- **Extensions to Structured/Dependent Inputs**: Correlated or highly collinear features, categorical variables, or grouped data challenge naive applications and benefit from coalitional or hierarchical extensions [2103.13342].
- **Stochastic/Probabilistic Settings**: When contributors supply samples from underlying distributions (rather than fixed deterministic objects), value and its variance must be estimated jointly—pooling and stratified resampling are under exploration [2601.14543].
- **Privacy and Federated Valuation**: Shapley estimation protocols must increasingly provide guarantees under privacy constraints, limited access, or distributed settings [2206.00511].

Potential directions include adaptive allocation schemes, distributed or federated value estimation, theoretically optimal sampling, and more expressive value functions (e.g., for calibrated probabilities or non-i.i.d. data).

---

**References**:  
- "The Shapley Value in Machine Learning" [2202.05594];  
- "Data valuation: The partial ordinal Shapley value for machine learning" [2305.01660];  
- "Accelerated Shapley Value Approximation for Data Evaluation" [2311.05346];  
- "Shapley Value on Probabilistic Classifiers" [2306.07171];  
- "An Efficient Shapley Value Computation for the Naive Bayes Classifier" [2307.16718];  
- "DU-Shapley: A Shapley Value Proxy for Efficient Dataset Valuation" [2306.02071];  
- "Differentially Private Shapley Values for Data Evaluation" [2206.00511];  
- "Shapley Value on Uncertain Data" [2601.14543];  
- "CS-Shapley: Class-wise Shapley Values for Data Valuation in Classification" [2211.06800];  
- "Beta Shapley: a Unified and Noise-reduced Data Valuation Framework for Machine Learning" [2110.14049];  
- "A Distributional Framework for Data Valuation" [2002.12334];  
- "Efficient computation and analysis of distributional Shapley values" [2007.01357];  
- "Probably Approximate Shapley Fairness with Applications in Machine Learning" [2212.00630];  
- "Provably Accurate Shapley Value Estimation via Leverage Score Sampling" [2410.01917];  
- "Shapley Values: Paired-Sampling Approximations" [2508.12947];  
- "The Shapley Value of coalition of variables provides better explanations" [2103.13342];  
- "Explaining the data or explaining a model? Shapley values that uncover non-linear dependencies" [2007.06011].

Source: https://www.emergentmind.com/topics/shapley-value-in-machine-learning