pydvl.valuation.types
¶
ValueUpdate
dataclass
¶
ValueUpdates are emitted by evaluation strategies.
Typically, a value update is the product of a marginal utility, the sampler weight and the valuation's coefficient. Instead of multiplying weights, coefficients and utilities directly, the strategy works in log-space for numerical stability using the samplers' log-weights and the valuation methods' log-coefficients.
The updates from all workers are converted back to linear space by LogResultUpdater.
ATTRIBUTE | DESCRIPTION |
---|---|
idx |
Index of the sample the update corresponds to.
TYPE:
|
log_update |
Logarithm of the absolute value of the update.
TYPE:
|
sign |
Sign of the update.
TYPE:
|
Source code in src/pydvl/valuation/types.py
Sample
dataclass
¶
Sample(idx: IndexT | None, subset: NDArray[IndexT])
__hash__
¶
This type must be hashable for the utility caching to work. We use hashlib.sha256 which is about 4-5x faster than hash(), and returns the same value in all processes, as opposed to hash() which is salted in each process
Source code in src/pydvl/valuation/types.py
with_idx_in_subset
¶
Return a copy of sample with idx added to the subset.
Returns the original sample if idx was already part of the subset.
RETURNS | DESCRIPTION |
---|---|
Sample
|
A copy of the sample with idx added to the subset.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If idx is None. |
Source code in src/pydvl/valuation/types.py
with_idx
¶
Return a copy of sample with idx changed.
Returns the original sample if idx is the same.
PARAMETER | DESCRIPTION |
---|---|
idx
|
New value for idx.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Sample
|
A copy of the sample with idx changed.
TYPE:
|
Source code in src/pydvl/valuation/types.py
with_subset
¶
with_subset(subset: NDArray[IndexT]) -> Self
Return a copy of sample with subset changed.
Returns the original sample if subset is the same.
PARAMETER | DESCRIPTION |
---|---|
subset
|
New value for subset.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Sample
|
A copy of the sample with subset changed.
TYPE:
|
Source code in src/pydvl/valuation/types.py
ClasswiseSample
dataclass
¶
ClasswiseSample(
idx: IndexT | None,
subset: NDArray[IndexT],
label: int,
ooc_subset: NDArray[IndexT],
)
Bases: Sample
Sample class for classwise shapley valuation
ooc_subset
instance-attribute
¶
ooc_subset: NDArray[IndexT]
Indices of out-of-class elements, i.e., those with a label different from this sample's label
with_idx_in_subset
¶
Return a copy of sample with idx added to the subset.
Returns the original sample if idx was already part of the subset.
RETURNS | DESCRIPTION |
---|---|
Sample
|
A copy of the sample with idx added to the subset.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If idx is None. |
Source code in src/pydvl/valuation/types.py
with_idx
¶
Return a copy of sample with idx changed.
Returns the original sample if idx is the same.
PARAMETER | DESCRIPTION |
---|---|
idx
|
New value for idx.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Sample
|
A copy of the sample with idx changed.
TYPE:
|
Source code in src/pydvl/valuation/types.py
with_subset
¶
with_subset(subset: NDArray[IndexT]) -> Self
Return a copy of sample with subset changed.
Returns the original sample if subset is the same.
PARAMETER | DESCRIPTION |
---|---|
subset
|
New value for subset.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Sample
|
A copy of the sample with subset changed.
TYPE:
|