319 introduces PermutationSampler but it does not include the possibility of interrupting the sampling within a permutation, as required for TCMS.
One possibility would be to make samplers not simple Iterables but coroutines, with __iter__ returning a Generator[NDArray, bool, None] that accepts sent booleans to interrupt the sampling of a permutation. With this (and given that caching is enabled, see the comment in semivalues.py, but this is unrelated to the interruption), permutation_montecarlo_shapley and semivalues with shapley_coefficient and PermutationSampler should be equivalent.
Additionally, stratified samplers might require either simple interruption, or information from the utility computations. For instance, an adaptive variance-reducing sampler might require the status (running moments?) for each stratum separately.
319 introduces
PermutationSampler
but it does not include the possibility of interrupting the sampling within a permutation, as required for TCMS.One possibility would be to make samplers not simple
Iterables
but coroutines, with__iter__
returning aGenerator[NDArray, bool, None]
that accepts sent booleans to interrupt the sampling of a permutation. With this (and given that caching is enabled, see the comment insemivalues.py
, but this is unrelated to the interruption),permutation_montecarlo_shapley
andsemivalues
withshapley_coefficient
andPermutationSampler
should be equivalent.Additionally, stratified samplers might require either simple interruption, or information from the utility computations. For instance, an adaptive variance-reducing sampler might require the status (running moments?) for each stratum separately.