pydvl.valuation.samplers.permutation
¶
Permutation-based samplers.
TODO: explain the formulation and the different samplers.
References¶
-
Mitchell, Rory, Joshua Cooper, Eibe Frank, and Geoffrey Holmes. Sampling Permutations for Shapley Value Estimation. Journal of Machine Learning Research 23, no. 43 (2022): 1–46. ↩
-
Watson, Lauren, Zeno Kujawa, Rayna Andreeva, Hao-Tsung Yang, Tariq Elahi, and Rik Sarkar. Accelerated Shapley Value Approximation for Data Evaluation. arXiv, 9 November 2023. ↩
PermutationSampler
¶
PermutationSampler(
truncation: TruncationPolicy | None = None, seed: Seed | None = None
)
Bases: StochasticSamplerMixin
, IndexSampler
Sample permutations of indices and iterate through each returning increasing subsets, as required for the permutation definition of semi-values.
For a permutation (3,1,4,2)
, this sampler returns in sequence the following
[Samples][pydvl.valuation.samplers.Sample] (tuples of index and subset):
(3, {3})
, (1, {3,1})
, (4, {3,1,4})
and (2, {3,1,4,2})
.
Batching
PermutationSamplers always batch their outputs to include a whole permutation of the index set, i.e. the batch size is always the number of indices.
PARAMETER | DESCRIPTION |
---|---|
truncation |
A policy to stop the permutation early.
TYPE:
|
seed |
Seed for the random number generator.
TYPE:
|
Source code in src/pydvl/valuation/samplers/permutation.py
generate_batches
¶
Batches the samples and yields them.
Source code in src/pydvl/valuation/samplers/base.py
AntitheticPermutationSampler
¶
AntitheticPermutationSampler(
truncation: TruncationPolicy | None = None, seed: Seed | None = None
)
Bases: PermutationSampler
Samples permutations like PermutationSampler, but after each permutation, it returns the same permutation in reverse order.
This sampler was suggested in (Mitchell et al. 2022)1
New in version 0.7.1
Source code in src/pydvl/valuation/samplers/permutation.py
generate_batches
¶
Batches the samples and yields them.
Source code in src/pydvl/valuation/samplers/base.py
DeterministicPermutationSampler
¶
DeterministicPermutationSampler(
truncation: TruncationPolicy | None = None, seed: Seed | None = None
)
Bases: PermutationSampler
Samples all n! permutations of the indices deterministically, and iterates through them, returning sets as required for the permutation-based definition of semi-values.
Source code in src/pydvl/valuation/samplers/permutation.py
generate_batches
¶
Batches the samples and yields them.
Source code in src/pydvl/valuation/samplers/base.py
PermutationEvaluationStrategy
¶
PermutationEvaluationStrategy(
sampler: PermutationSampler,
utility: UtilityBase,
coefficient: Callable[[int, int], float] | None = None,
)
Bases: EvaluationStrategy[PermutationSampler, ValueUpdate]
Computes marginal values for permutation sampling schemes.
This strategy iterates over permutations from left to right, computing the marginal utility wrt. the previous one at each step to save computation.