@@ -205,7 +205,10 @@ The value $v$ of the $i$-th sample in dataset $D$ wrt. utility $u$ is computed
205205as a weighted sum of its marginal utility wrt. every possible coalition of
206206training samples within the training set:
207207
208- $$v_u(x_i) = \f rac{1}{n} \s um_{S \s ubseteq D \s etminus \{ x_i\} } \b inom{n-1}{ | S | }^{-1} [u(S \c up \{ x_i\} ) − u(S)] ,$$
208+ $$
209+ v_u(x_i) = \f rac{1}{n} \s um_{S \s ubseteq D \s etminus \{ x_i\} }
210+ \b inom{n-1}{ | S | }^{-1} [u(S \c up \{ x_i\} ) − u(S)]
211+ ,$$
209212
210213.. code-block :: python
211214
@@ -253,7 +256,10 @@ of the utility from $\{0,1\}^n$, where a 1 in position $i$ means that sample
253256$x_i$ is used to train the model, to $[0,1]^n$. The ensuing expression for
254257Shapley value uses integration instead of discrete weights:
255258
256- $$v_u(i) = \i nt_0^1 \m athbb{E}_{S \s im P_q(D_{\b ackslash \{ i \} })} [u(S \c up {i}) - u(S)].$$
259+ $$
260+ v_u(i) = \i nt_0^1 \m athbb{E}_{S \s im P_q(D_{\b ackslash \{ i \} })}
261+ [u(S \c up {i}) - u(S)]
262+ .$$
257263
258264Using Owen sampling follows the same pattern as every other method for Shapley
259265values in pyDVL. First construct the dataset and utility, then call
@@ -282,7 +288,10 @@ Permutation Shapley
282288An equivalent way of computing Shapley values appears often in the literature.
283289It uses permutations over indices instead of subsets:
284290
285- $$v_u(x_i) = \f rac{1}{n!} \s um_{\s igma \i n \P i(n)} [u(\s igma_{i-1} \c up {i}) − u(\s igma_{i})],$$
291+ $$
292+ v_u(x_i) = \f rac{1}{n!} \s um_{\s igma \i n \P i(n)}
293+ [u(\s igma_{i-1} \c up {i}) − u(\s igma_{i})]
294+ ,$$
286295
287296where $\s igma_i$ denotes the set of indices in permutation sigma up until the
288297position of index $i$. To approximate this sum (with $\m athcal{O}(n!)$ terms!)
@@ -324,13 +333,131 @@ and can be used in pyDVL with:
324333 utility = Utility(model, data)
325334 values = compute_shapley_values(u = utility, mode = " knn" )
326335
336+ .. _Least Core :
337+
338+ Core values
339+ ===========
340+
341+ The Shapley values define a fair way to distribute payoffs amongst all
342+ participants when they form a grand coalition. But they do not consider
343+ the question of stability: under which conditions do all participants
344+ form the grand coalition? Would the participants be willing to form
345+ the grand coalition given how the payoffs are assigned,
346+ or would some of them prefer to form smaller coalitions?
347+
348+ The Core is another approach to computing data values originating
349+ in cooperative game theory that attempts to ensure this stability.
350+ It is the set of feasible payoffs that cannot be improved upon
351+ by a coalition of the participants.
352+
353+ It satisfies the following 2 properties:
354+
355+ - **Efficiency **:
356+ The payoffs are distributed such that it is not possible
357+ to make any participant better off
358+ without making another one worse off.
359+ $$\s um_{x_i\i n D} v_u(x_i) = u(D)\, $$
360+
361+ - **Coalitional rationality **:
362+ The sum of payoffs to the agents in any coalition S is at
363+ least as large as the amount that these agents could earn by
364+ forming a coalition on their own.
365+ $$\s um_{x_i\i n S} v_u(x_i) \g eq u(S), \f orall S \s ubseteq D\, $$
366+
367+ The second property states that the sum of payoffs to the agents
368+ in any subcoalition $S$ is at least as large as the amount that
369+ these agents could earn by forming a coalition on their own.
370+
371+ Least Core values
372+ ^^^^^^^^^^^^^^^^^
373+
374+ Unfortunately, for many cooperative games the Core may be empty.
375+ By relaxing the coalitional rationality property by $e \g t 0$,
376+ we are then able to find approximate payoffs:
377+
378+ $$
379+ \s um_{x_i\i n S} v_u(x_i) + e \g eq u(S), \f orall S \s ubseteq D\
380+ ,$$
381+
382+ The least core value $v$ of the $i$-th sample in dataset $D$ wrt.
383+ utility $u$ is computed by solving the following Linear Program:
384+
385+ $$
386+ \b egin{array}{lll}
387+ \t ext{minimize} & e & \\
388+ \t ext{subject to} & \s um_{x_i\i n D} v_u(x_i) = u(D) & \\
389+ & \s um_{x_i\i n S} v_u(x_i) + e \g eq u(S) &, \f orall S \s ubseteq D \\
390+ \e nd{array}
391+ $$
392+
393+ Exact Least Core
394+ ----------------
395+
396+ This first algorithm is just a verbatim implementation of the definition.
397+ As such it returns as exact a value as the utility function allows
398+ (see what this means in :ref: `problems of data values `).
399+
400+ .. code-block :: python
401+
402+ from pydvl.utils import Dataset, Utility
403+ from pydvl.value.least_core import exact_least_core
404+ model = ...
405+ dataset = Dataset(... )
406+ utility = Utility(data, model)
407+ values = exact_least_core(utility)
408+
409+ Monte Carlo Least Core
410+ ----------------------
411+
412+ Because the number of subsets $S \s ubseteq D \s etminus \{ x_i\} $ is
413+ $2^{ | D | - 1 }$, one typically must resort to approximations.
414+
415+ The simplest approximation consists of two relaxations of the Least Core
416+ (:footcite:t: `yan_procaccia_2021 `):
417+
418+ - Further relaxing the coalitional rationality property by
419+ a constant value $\e psilon > 0$:
420+
421+ $$
422+ \s um_{x_i\i n S} v_u(x_i) + e + \e psilon \g eq u(S)
423+ $$
424+
425+ - Using a fraction of all subsets instead of all possible subsets.
426+
427+ Combined, this gives us the following property:
428+
429+ $$
430+ P_{S\s im D}\l eft[\s um_{x_i\i n S} v_u(x_i) + e^{*} + \e psilon \g eq u(S)\r ight]
431+ \g eq 1 - \d elta
432+ $$
433+
434+ Where $e^{*}$ is the optimal least core value.
435+
436+ With these relaxations, we obtain a polynomial running time.
437+
438+ .. code-block :: python
439+
440+ from pydvl.utils import Dataset, Utility
441+ from pydvl.value.least_core import montecarlo_least_core
442+ model = ...
443+ dataset = Dataset(... )
444+ max_iterations = ...
445+ utility = Utility(data, model)
446+ values = montecarlo_least_core(utility, max_iterations = max_iterations)
447+
448+ .. note ::
449+
450+ ``max_iterations `` needs to be at least equal to the number of data points.
327451
328452Other methods
329453=============
330454
331- Other game-theoretic concepts in pyDVL's roadmap are the **Least Core ** (in
332- progress), and **Banzhaf indices ** (the latter is just a different weighting
333- scheme with better numerical stability properties). Contributions are welcome!
455+ There are other game-theoretic concepts in pyDVL's roadmap, based on the notion
456+ of semivalue, which is a generalization to different weighting schemes:
457+ in particular **Banzhaf indices ** and **Beta Shapley **, with better numerical
458+ and rank stability in certain situations.
459+
460+ Contributions are welcome!
334461
335462
336463.. _problems of data values :
0 commit comments