Skip to content

Commit 5d4775c

Browse files
committed
Docstring fixes
1 parent 0e33aa8 commit 5d4775c

File tree

2 files changed

+30
-29
lines changed

2 files changed

+30
-29
lines changed

src/pydvl/valuation/methods/owen_shapley.py

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
r"""
2-
!!! Fixme "Move this to the docs"
3-
2+
FIXME: Move this to the docs
43
54
Owen sampling schemes are a family of sampling schemes that are used to estimate
65
Shapley values. They are based on a multilinear extension technique from game theory,
@@ -10,18 +9,19 @@
109
In order to compute values it is enough to use any of the Owen samplers together with a
1110
[ShapleyValuation][pydvl.valuation.methods.ShapleyValuation] object.
1211
13-
!!! Example "Finite Owen Sampler"
14-
[OwenSampler][pydvl.valuation.samplers.owen.OwenSampler] with a
15-
[FiniteSequentialIndexIteration][pydvl.valuation.iteration.FiniteSequentialIndexIteration]
16-
for the outer loop and a
17-
[GridOwenStrategy][pydvl.valuation.samplers.owen.GridOwenStrategy] for the sampling
18-
probabilities is the most basic Owen sampler. It uses a deterministic grid of
19-
probability values between 0 and 1 for the inner sampling. It follows the idea of
20-
the original paper and should be instantiated with
21-
[NoStopping][pydvl.valuation.stopping.NoStopping] as stopping criterion. Note that
22-
because the criterion never checks for convergence, the status of the valuation will
23-
always be `Status.Pending`.
12+
## Finite Owen Sampler
13+
[OwenSampler][pydvl.valuation.samplers.owen.OwenSampler] with a
14+
[FiniteSequentialIndexIteration][pydvl.valuation.samplers.powerset.FiniteSequentialIndexIteration]
15+
for the outer loop and a
16+
[GridOwenStrategy][pydvl.valuation.samplers.owen.GridOwenStrategy] for the sampling
17+
probabilities is the most basic Owen sampler. It uses a deterministic grid of
18+
probability values between 0 and 1 for the inner sampling. It follows the idea of
19+
the original paper and should be instantiated with
20+
[NoStopping][pydvl.valuation.stopping.NoStopping] as stopping criterion. Note that
21+
because the criterion never checks for convergence, the status of the valuation will
22+
always be `Status.Pending`.
2423
24+
??? Example
2525
```python
2626
from pydvl.valuation import OwenSampler, ShapleyValuation, NoStopping
2727
...
@@ -36,14 +36,15 @@
3636
shapley_values = valuation.values()
3737
```
3838
39-
!!! Example "Owen Sampler"
40-
[OwenSampler][pydvl.valuation.samplers.owen.OwenSampler] follows the same principle
41-
as [OwenSampler][pydvl.valuation.samplers.owen.OwenSampler], but samples
42-
probability values between 0 and 1 at random indefinitely. It requires a stopping
43-
criterion to be used with the valuation method, and thus follows more closely the
44-
general pattern of the valuation methods. This makes it more adequate for actual use
45-
since it is no longer required to estimate a number of outer samples required.
39+
## Owen Sampler
40+
[OwenSampler][pydvl.valuation.samplers.owen.OwenSampler] follows the same principle
41+
as [OwenSampler][pydvl.valuation.samplers.owen.OwenSampler], but samples
42+
probability values between 0 and 1 at random indefinitely. It requires a stopping
43+
criterion to be used with the valuation method, and thus follows more closely the
44+
general pattern of the valuation methods. This makes it more adequate for actual use
45+
since it is no longer required to estimate a number of outer samples required.
4646
47+
!!! Example
4748
```python
4849
from pydvl.valuation import OwenSampler, ShapleyValuation, RankCorrelation
4950
...
@@ -53,13 +54,14 @@
5354
valuation.fit(dataset)
5455
```
5556
56-
!!! Example "Antithetic Owen Sampler"
57-
[AntitheticOwenSampler][pydvl.valuation.samplers.owen.AntitheticOwenSampler] is a
58-
variant of the [OwenSampler][pydvl.valuation.samplers.owen.OwenSampler] that draws
59-
probability values $q$ between 0 and 0.5 at random and then generates two samples
60-
for each index, one using the probability $q$ for index draws, and another with
61-
probability $1-q$.
57+
## Antithetic Owen Sampler
58+
[AntitheticOwenSampler][pydvl.valuation.samplers.owen.AntitheticOwenSampler] is a
59+
variant of the [OwenSampler][pydvl.valuation.samplers.owen.OwenSampler] that draws
60+
probability values $q$ between 0 and 0.5 at random and then generates two samples
61+
for each index, one using the probability $q$ for index draws, and another with
62+
probability $1-q$.
6263
64+
!!! Example
6365
```python
6466
from pydvl.valuation import AntitheticOwenSampler, ShapleyValuation, RankCorrelation
6567
...

src/pydvl/valuation/methods/semivalue.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,13 @@
4646
class SemivalueValuation(Valuation):
4747
r"""Abstract class to define semi-values.
4848
49-
Implementations must only provide the `coefficient()` method, corresponding
49+
Implementations must only provide the `log_coefficient()` method, corresponding
5050
to the semi-value coefficient.
5151
5252
!!! Note
5353
For implementation consistency, we slightly depart from the common definition
5454
of semi-values, which includes a factor $1/n$ in the sum over subsets.
5555
Instead, we subsume this factor into the coefficient $w(k)$.
56-
TODO: see ...
5756
5857
Args:
5958
utility: Object to compute utilities.
@@ -91,7 +90,7 @@ def __init__(
9190

9291
@abstractmethod
9392
def log_coefficient(self, n: int, k: int) -> float:
94-
"""The semi-value coefficient in log-space/
93+
"""The semi-value coefficient in log-space.
9594
9695
The semi-value coefficient is a function of the number of elements in the set,
9796
and the size of the subset for which the coefficient is being computed.

0 commit comments

Comments
 (0)