shapiq.approximator.OddSHAP¶
- class shapiq.approximator.OddSHAP(n, *, sampling_weights=None, random_state=None, interaction_factor=10, tree_params=None, **kwargs)[source]¶
Bases:
ApproximatorOddSHAP approximator for first-order Shapley values (Fumagalli et al., 2026).
Note
Where Algorithm 1 of the paper falls back to TreeSHAP for budgets below
n * interaction_factor, this implementation expands the selection of active terms also to individuals, allowing a minimum budget ofinteraction_factor. Below that, it raisesValueError(no silent downgrade to another estimator), unless the budget already covers the full coalition space (budget >= 2**n). It therefore does not reproduce the low-budget, high-dimension regime of the paper’s Figure 2.The active support’s candidate budget (
ceil(budget / interaction_factor)) is shared between individuals and higher-order odd interactions: the most relevant individuals (ranked by absolute Fourier coefficient, allnof them always considered) are screened first, and only the remaining candidate budget is spent on higher-order odd interactions. Unlike the paper, low budgets can therefore leave some individuals out of the active support entirely (their Shapley value is then estimated as exactly 0).Initialize the OddSHAP approximator.
tree_paramsentries override the surrogate defaults — includingrandom_state,n_jobs, andverbose;max_depthdefaults to 10 (the paper’s configuration) unless overridden.- Parameters:
- approximate(budget, game, **kwargs)[source]¶
Approximate first-order Shapley values.
The method samples coalitions, evaluates the game, detects sparse odd interactions, solves the constrained odd Fourier regression problem, and transforms the fitted coefficients into Shapley values.
- Parameters:
- Return type:
- Returns:
Estimated first-order Shapley values.
- Raises:
ValueError – If
budget < min(interaction_factor, 2**n), i.e. the budget is below the eta-based minimum and does not cover the full coalition space either. Algorithm 1 of the paper falls back to TreeSHAP in this regime; this implementation deliberately raises instead, so an under-budgeted call never silently returns a different estimator’s values.RuntimeError – If the sampled coalitions do not contain the empty or grand coalition.