Skip to content

Commit 189488f

Browse files
Advueu963mmschlk
andauthored
docs: Added docstring to UnanimityGame & SOUM (mmschlk#420)
* docs: Added docstring to UnanimityGame & SOUM * adds changelog entry for bugfix --------- Co-authored-by: Maximilian <maximilian.muschalik@gmail.com>
1 parent f44e1c2 commit 189488f

3 files changed

Lines changed: 32 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ This restructuring aims to improve maintainability and development scalability.
1818
### Docs
1919
- added an example notebook for `InteractionValues`, highlighting *Initialisation*, *Modification*, *Visualization* and *Save and Loading*.
2020

21+
### Bugfixes
22+
- fixes a bug where RegressionFBII approximator was throwing an error when the index was `'BV'` or `'FBII'`.[#420](https://github.com/mmschlk/shapiq/pull/420)
23+
2124
## v1.3.1 (2025-07-11)
2225

2326
### New Features

src/shapiq/approximator/regression/faithful.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
ValidRegressionFSIIIndices = Literal["FSII", "SV"]
16-
ValidRegressionFBIIIndices = Literal["FBII", "SV"]
16+
ValidRegressionFBIIIndices = Literal["FBII", "BV"]
1717

1818

1919
class RegressionFSII(Regression):

src/shapiq_games/synthetic/soum.py

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,23 @@
2020

2121

2222
class UnanimityGame(Game):
23-
"""The Unanimity basis game.
23+
r"""The Unanimity basis game.
2424
2525
Unanimity games are basis games from cooperative game theory. They are based on a single
2626
interaction and return 1 if the coalition contains the interaction and 0 otherwise.
2727
28-
# TODO(mmshlk): add a reference and a formal description of the Unanimity game
29-
# https://github.com/mmschlk/shapiq/issues/387
28+
More formally the Unanimity game is defined based on an interaction :math:`T`, which is a tuple of player indices.
29+
The cooperative game is defined as follows:
30+
.. math::
31+
:nowrap:
32+
33+
\begin{eqnarray}
34+
v(S) & = & 1 if T \\subseteq S \\
35+
& = & 0 otherwise
36+
\\end{eqnarray}
3037
3138
Attributes:
32-
interaction_binary: The interaction encoded in a binary vector of length ``n``.
39+
interaction_binary: The interaction $T$ encoded in a binary vector of length ``n``.
3340
interaction: The interaction encoded as a tuple.
3441
3542
Examples:
@@ -67,25 +74,37 @@ def value_function(self, coalitions: np.ndarray) -> np.ndarray[float]:
6774

6875

6976
class SOUM(Game):
70-
"""The Sum of Unanimity Game (SOUM) game class.
77+
r"""The Sum of Unanimity Game (SOUM) game class.
7178
7279
A Sum of Unanimity Game (SOUM) constructs a game based on linear combinations of so-called
7380
unanimity games (:class:`~shapiq_games.benchmark.synthetic.soum.UnanimityGame`).
7481
75-
# TODO(mmshlk): extend description of the SOUM, add a reference and a formal description
76-
# https://github.com/mmschlk/shapiq/issues/387
82+
Based on a sequence of Unanimity games :math:`U_1, U_2, \\ldots, U_n` with linear coefficients :math:`c_1, c_2, \\ldots, c_n`
83+
the SOUM is defined as follows:
84+
.. math::
85+
:nowrap:
86+
\begin{eqnarray}
87+
v(S) & = & \\sum_{i=1}^{n} c_i \\cdot v_{U_i}(S) \\
88+
v_{U_i}(S) & = & \begin{cases}
89+
1 & \text{if } T_i \\subseteq S \\
90+
0 & \text{otherwise}
91+
\\end{cases}
92+
\\end{eqnarray}
93+
94+
where :math:`T_i` is the interaction of the :class:`~shapiq_games.benchmark.synthetic.soum.UnanimityGame` :math:`U_i`.
95+
The linear coefficients :math:`c_i` are randomly sampled from the interval :math:`[-1, 1]`.
7796
7897
Attributes:
7998
n_players: The number of players.
8099
81-
n_basis_games: The number of Unanimity gams
100+
n_basis_games: The number of Unanimity games.
82101
83102
unanimity_games: A dictionary containing instances of :class:`~shapiq_games.benchmark.synthetic.soum.UnanimityGame`.
84103
85104
linear_coefficients: A numpy array with coefficients between -1 and 1 for the unanimity
86105
games.
87106
88-
min_interaction_size: The smallest interaction size
107+
min_interaction_size: The smallest interaction size.
89108
90109
max_interaction_size: The highest interaction size.
91110

0 commit comments

Comments
 (0)