Search

Search papers and lessons

Data Shapley: Equitable Valuation of Data for Machine Learning

Amirata Ghorbani, James Zou · 2019

Data Shapley gives each training example a value equal to its average contribution to model performance over all subsets of the data, and a sampling method makes that average affordable to estimate.

On this page

  • Colour = topic mix
  • Probability
  • Discrete math
  • Calculus
  • Learning basics
  • Game theory
  • Sampling
  • ReadReady to readNot yet

TL;DR

Data Shapley assigns each training example a number: its average contribution to the performance of the model trained on every possible subset of the data. The average is the Shapley Value from game theory, and it is the only valuation that meets three fairness-style conditions the authors state. Because exact computation needs exponentially many trained models, the paper estimates it by sampling orderings of the data and stopping early, which makes it practical for neural networks on large datasets. The medical examples are illustrations of a method, not medical advice.

Builds on: Shapley Value, Supervised Learning, Monte Carlo Method · Leads to: Domain Adaptation

Why it mattered

The paper gave machine learning a precise answer to a question that had been asked informally: how much is one piece of data worth? The paper's own experiments use it to find mislabelled examples, to decide which new data to collect, and to reweight training sets when the deployment data differs from the training data. Its authors frame the value as a basis for compensating people whose data is used, and they are careful to say that the number is a measurement tool, not a price.

Applications in the paper include a patient dataset with 285 features, a skin lesion classifier trained on cheap web images, and a gender classifier trained on a set with unequal representation. Each is covered in the Results section. The method is also an example of a wider move in machine learning to borrow ideas from cooperative game theory, which also appears in SHAP Values for explaining predictions, although that work values features while this one values data points.

The problem

Suppose you have a training set, a learning algorithm that turns a training set into a model, and a score that says how good the model is on held-out data. Each training point has some effect on the score, but that effect depends on which other points are present. A point that is redundant with a large clean dataset may matter a lot when it is the only example of its kind.

The simplest valuation is leave-one-out: train with all the data, then again without point ii, and measure the drop. It ignores every subset except the full set, so a duplicate point looks worthless when it is really useful. The authors ask what a fair valuation must satisfy. Their conditions are stated in words: a point that never changes the score should be worth zero; two points that contribute equally to every subset should be worth the same; and if the score is a sum of separate scores, the value should be the sum of the values for each score. Their answer is a unique formula, but the formula needs one trained model per subset, which is far too many.

How it works

The method has three inputs (the training data, the learning algorithm and the score), one sampling loop, and one output: a value for each point. Here it is traced on a toy game with three points, where the score of each subset is given in advance. These numbers are illustrative and are not from the paper.

Subset∅\varnothing{1}\{1\}{2}\{2\}{3}\{3\}{1,2}\{1,2\}{1,3}\{1,3\}{2,3}\{2,3\}{1,2,3}\{1,2,3\}
Score02203223
  1. Start with the full set and an empty model score. The score of the empty set is 0, and the score of the full set {1,2,3}\{1,2,3\} is 3. Check: the three values must split the total of 3 between them.
  2. Draw one random order of the points. Take the order 3,1,23, 1, 2. Add the points one at a time and record how much the score rises at each step. Point 3 goes from 0 to 0, so it adds 0. Point 1 goes from the score of {3}\{3\}, which is 0, to the score of {1,3}\{1, 3\}, which is 2, so it adds 2. Point 2 goes from 2 to 3, so it adds 1. Check: the three increases add up to 3−0=33 - 0 = 3, the total score.
  3. Repeat for every order and average. There are six orders. The table below shows what each point adds in each order.
OrderPoint 1 addsPoint 2 addsPoint 3 adds
1, 2, 3210
1, 3, 2210
2, 1, 3120
2, 3, 1120
3, 1, 2210
3, 2, 1120

Averaging gives ϕ1=9/6=1.5\phi_1 = 9/6 = 1.5, ϕ2=9/6=1.5\phi_2 = 9/6 = 1.5 and ϕ3=0\phi_3 = 0. Check: the values sum to 3, the score of the full set.

  1. Read the result. Points 1 and 2 are interchangeable in this game, so they get the same value. Point 3 never adds anything to a larger set, so it is worth nothing. This is the null-point condition in action.
  2. Speed it up by sampling. With nn points there are n!n! orders, which becomes impossible very fast. The paper samples random orders instead, and then stops scanning an order early once the score is within a set tolerance of the full-data score. Later points in that order add almost nothing, so their contributions are set to zero. Check: with three points this saves little, but with thousands of points most of each order is skipped.
flowchart LR
  A[Training data, learner, score] --> B[Draw a random order]
  B --> C[Add points one at a time]
  C --> D{Score close to full-data score?}
  D -- no --> C
  D -- yes --> E[Give the rest zero]
  E --> F[Average over orders]
  F --> G[One value per point]

The math

The formal definition has three parts: the value of a subset, the Shapley formula built from marginal contributions, and the sampling estimate used in practice.

Step 1 in symbols: the value of a subset

Let D={1,…,n}D = \{1, \dots, n\} index the training points, let A\mathcal{A} be the learning algorithm, and let V(S)V(S) be the score of the model trained on subset S⊆DS \subseteq D. The score is a black box: it trains a model on SS and measures it on held-out data. In the toy game, V({1,3})=2V(\{1,3\}) = 2 means that training on points 1 and 3 gives score 2.

Step 2 in symbols: the Shapley formula

The marginal contribution of point ii to a subset SS that does not contain it is V(S∪{i})−V(S)V(S \cup \{i\}) - V(S). The paper's Equation 1 averages these over all subsets of the other points, with a weight that depends only on the subset size:

ϕi=C∑S⊆D∖{i}V(S∪{i})−V(S)(n−1∣S∣).\phi_i = C \sum_{S \subseteq D \setminus \{i\}} \frac{V(S \cup \{i\}) - V(S)}{\binom{n-1}{|S|}}.

Here (n−1∣S∣)\binom{n-1}{|S|} is the number of subsets of the same size, and CC is a constant. The authors show that three conditions (the null-point condition, equal treatment of interchangeable points, and additivity over separate scores) force this form. Choosing C=1/nC = 1/n gives the standard Shapley value of a cooperative game, which is what the toy example computes. Check: with n=3n = 3, the weight before the constant is 1/(20)=11/\binom{2}{0} = 1 for a subset of size 0 and 1/(21)=1/21/\binom{2}{1} = 1/2 for a subset of size 1, so the constant C=1/3C = 1/3 turns these into the usual weights 1/31/3 and 1/61/6.

Step 3 in symbols: the sampling estimate

The Shapley value is also the expected marginal contribution when the order of points is drawn uniformly at random. If π\pi is a random order and PiπP_i^\pi is the set of points before ii in that order, then

ϕi=Eπ ⁣[V(Piπ∪{i})−V(Piπ)].\phi_i = \mathbb{E}_{\pi}\!\left[ V(P_i^\pi \cup \{i\}) - V(P_i^\pi) \right].

Averaging the marginal contributions over tt sampled orders gives an estimate that approaches ϕi\phi_i as tt grows. The paper's Algorithm 1 keeps a running average, so each new sample updates the estimate without storing the old ones:

ϕi←t−1t ϕi+1t(vjt−vj−1t),\phi_i \leftarrow \frac{t-1}{t}\,\phi_i + \frac{1}{t}\left( v_j^t - v_{j-1}^t \right),

where vjtv_j^t is the score after the first jj points of the tt-th order, and ii is the jj-th point in that order.

Step 4 in symbols: the truncation rule

Let V(D)V(D) be the score on the full data, and let τ>0\tau > 0 be the performance tolerance. Algorithm 1 keeps adding points to an order only while

∣V(D)−vj−1t∣≥τ.\left| V(D) - v_{j-1}^t \right| \ge \tau.

Once the current score is within τ\tau of V(D)V(D), the remaining points get zero marginal contribution. This is an approximation, and the authors justify it by the observation that adding points to a large set changes the score less and less.

Results

The paper reports results on several datasets. The numbers below are copied from its text.

  • Disease prediction from patient records. Using logistic regression on 285 features, held-out accuracy was 68.7% for breast cancer and 56.4% for skin cancer, on 1,000 held-out patients. Removing the most valuable training points lowered accuracy, and removing the least valuable points raised it.
  • Domain adaptation for skin lesions. Training on 1,155 cheap web images, with negative-value images removed and the rest reweighted, raised accuracy on 400 expert-labelled images from 29.6% to 37.8%.
  • Gender classification. Adapting from a training set with unequal representation to a balanced target set raised accuracy from 84.1% to 91.5% on 400 target images.
  • Clinical notes. Adapting a recurrent note-tagging model from one institution's notes to another raised average accuracy for the ten most frequent diagnoses from 87.5% to 90.1%.
  • Approximation quality on small problems. For synthetic datasets with 4 to 14 points and logistic regression, the Pearson correlation between the exact and the TMC estimate was between 98.4% and 99.5%.
  • Approximation quality on larger problems. The correlation between the two approximation methods was 0.9 to 0.95 for logistic regression on synthetic data with 100 points, and 0.7 to 0.8 with a neural network. On a label-flip task it was 0.62 for Fashion-MNIST and 0.57 for flowers.

The limits matter as much as the gains. The value of a point depends on the learning algorithm, the score and the other points, so a value is only meaningful in its context. The exact formula is exponential, and the estimates are noisier for neural networks. The paper also says that its three conditions are a starting point, not a complete account of what a fair value is, and that privacy and personal meaning are outside the framework.

Reading guide

  • Abstract and introduction. Read them with Supervised Learning in mind. The three ingredients are the training set, the learner and the metric, and the paper's question is about how the value of one example depends on all three.
  • Overview and the three properties. The leave-one-out idea is the comparison point. The conditions are stated in words first, and then the proposition gives the unique formula. The proof rests on the Shapley Value and on the Cooperative Game view, in which each training point is a player.
  • Algorithm 1 (TMC-Shapley). This is the sampling procedure. Its justification is in Monte Carlo Method, and the running-average update is a simple form of the averaging you can check with Expected Value.
  • Label noise and noisy images. The first experiments use a pre-trained Convolutional Neural Network with its top layer retrained, and three models, including Logistic Regression, for the mislabelled-data experiments.
  • Disease prediction and data acquisition. The second half uses a Random Forest to predict the value of candidate patients from their features. Read it as a method for prioritising data collection, not as a clinical study.
  • Domain adaptation. This section uses value to decide which points to drop and which to reweight, and it links to Domain Adaptation.
  • Appendix A and B. Appendix A covers the Monte Carlo details. Appendix B gives a gradient-based alternative, G-Shapley, which uses updates of the kind found in Stochastic Gradient Descent.
  • Appendix E. These checks compare approximations with exact values. Exact values need all 2n2^n subsets, which is the count in Counting Principles.
  • Related work. It compares the approach with SHAP Values and with leverage and Cook's distance, which measure influence but do not satisfy the fairness conditions.

Check yourself

QuestionRecall: what are the three conditions that the paper says a fair data valuation should satisfy?Show answer

A point that never changes the score should get zero value (the null-point condition). Two points that contribute equally to every subset should get the same value (equal treatment). And when the score is a sum of separate scores, the value should be the sum of the values for each score (additivity). The paper shows these conditions determine the Shapley formula up to a constant.

QuestionComputation: a game has two points with V(∅)=0V(\varnothing) = 0, V({1})=1V(\{1\}) = 1, V({2})=3V(\{2\}) = 3 and V({1,2})=4V(\{1,2\}) = 4. What are the Data Shapley values ϕ1\phi_1 and ϕ2\phi_2?Show answer

For point 1, the marginal contributions are V({1})−V(∅)=1V(\{1\}) - V(\varnothing) = 1 when it comes first, and V({1,2})−V({2})=1V(\{1,2\}) - V(\{2\}) = 1 when it comes second. Their average is (1+1)/2=1(1 + 1)/2 = 1. For point 2, the contributions are V({2})−V(∅)=3V(\{2\}) - V(\varnothing) = 3 and V({1,2})−V({1})=3V(\{1,2\}) - V(\{1\}) = 3, so ϕ2=(3+3)/2=3\phi_2 = (3 + 3)/2 = 3. Check: ϕ1+ϕ2=4=V({1,2})\phi_1 + \phi_2 = 4 = V(\{1,2\}).

QuestionWhy: why does the truncated algorithm stop adding points to an order once the score is close to the full-data score, and what does it risk?Show answer

Marginal contributions tend to shrink as the subset grows, because a large training set already captures most of what the model can learn. Once the score is within the tolerance of the full-data score, the points that remain add very little, so setting their contributions to zero saves most of the computation. The risk is a small bias: a point that would have added a little is credited with nothing. The tolerance controls the trade-off, and the paper's checks on small problems show the ordering of values is largely preserved.

QuestionApplied: a hospital research team wants to decide which new patients to recruit for a risk model. Could Data Shapley help, and what would you check before trusting the ranking?Show answer

It could help by valuing the current training patients, fitting a regression from patient features to value, and scoring a pool of candidate patients with that regression, as the paper does. Before trusting the ranking I would check that the score matches the purpose: a model tuned for overall accuracy can undervalue rare cases the hospital cares most about. I would also check that the values change little when the learner or the random sample changes, since the paper shows that approximations can disagree more for neural networks. Finally, the ranking is a research tool for choosing data to collect, and any use in patient care needs clinical validation and governance that this paper does not provide.

Sources

Read the full paper

Amirata Ghorbani, James Zou, 2019. arXiv:1904.02868