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 raisesValueErrorinstead (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.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(n * 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.