Skip to content

Add ShaplEIG: Bayesian experimental design approximator#548

Draft
david-rundel wants to merge 5 commits into
mmschlk:mainfrom
david-rundel:feature/shapleig
Draft

Add ShaplEIG: Bayesian experimental design approximator#548
david-rundel wants to merge 5 commits into
mmschlk:mainfrom
david-rundel:feature/shapleig

Conversation

@david-rundel

@david-rundel david-rundel commented Jun 12, 2026

Copy link
Copy Markdown

ShaplEIG fits a Gaussian process surrogate with a weighted Hamming product kernel on queried coalition values and sequentially selects coalitions by maximizing the closed-form expected information gain about the Shapley values. The Shapley structure is handled via elementary-symmetric-polynomial identities of the kernel's generating polynomials, so the 2^n coalition space is never enumerated.

  • new optional extra 'shapleig' (torch/gpytorch/botorch/linear_operator) with lazy import and an informative placeholder when not installed
  • shapiq/approximator/shapleig/: approximator + flat Hamming GP surrogate + self-contained ESP math core (controlled copy of the validated reference implementation, kept in sync)
  • order-1 SV InteractionValues output (min_order=0, baseline = empty coalition value); SV-variance return left as a commented scaffold until InteractionValues supports uncertainty information
  • tqdm progress bar over the BED iterations
  • registered in SV_APPROXIMATORS and the public API; unit tests covering output format, determinism, and convergence to ExactComputer ground truth

Motivation and Context

This PR adds ShaplEIG, an approximator for Shapley values based on Bayesian experimental design (BED), accompanying the paper "ShaplEIG: Bayesian Experimental Design for Shapley Value Estimation" (Rundel et al., 2026).

The scope was pre-agreed with @mmschlk and @Advueu963: a black-box, end-to-end approximator in shapiq/approximator/shapleig/ behind a new optional dependency group shapleig.

Open questions for the maintainers:

  • The shapleig extra is pinned to the exact versions used for the published experiments
    (torch==2.9.1, gpytorch==1.14, botorch==0.14.0, linear_operator==0.6). Is this ok?
  • The surrogate posterior also provides the marginal SV variances; the code contains a commented
    scaffold to expose them via an approximate_with_variance once InteractionValues supports
    uncertainty information (future work, as discussed).

Public API Changes

  • No Public API changes

  • Yes, Public API changes (Details below)

  • New public class shapiq.ShaplEIG (= shapiq.approximator.shapleig.ShaplEIG), registered in
    SV_APPROXIMATORS.

  • New optional dependency group shapleig in pyproject.toml.

  • No changes to any existing API. import shapiq works without the extra installed (the optional
    dependencies are imported in ShaplEIG.__init__, which raises an ImportError pointing to pip install 'shapiq[shapleig]' when they are missing).


How Has This Been Tested?

  • New unit tests in tests/shapiq/tests_unit/tests_approximators/test_approximator_shapleig.py:
    output format (InteractionValues, order 1, min_order=0, baseline = empty-coalition value),
    determinism under random_state, convergence to ExactComputer ground truth with growing budget,
    budget/candidate-set validation, sampled-candidate-subset and warmstart configurations.
  • Verified bit-identical against the validated reference implementation of the paper on the
    same game/seed/protocol (default and warmstart configurations).
  • Full local unit suite passes (852 passed; the only failures are pre-existing [spex] tests
    caused by the sparse extra not being installed locally, identical on main).

Checklist

  • The changes have been tested locally.
  • Documentation has been updated (if the public API or usage changes). (Not actively. Does the API reference pick
    ShaplEIG up via the shapiq.approximator autosummary?)
  • An entry has been added to CHANGELOG.md (if relevant for users).
  • The code follows the project's style guidelines.
  • I have considered the impact of these changes on the public API.

…alues

ShaplEIG fits a Gaussian process surrogate with a weighted Hamming product
kernel on queried coalition values and sequentially selects coalitions by
maximizing the closed-form expected information gain about the Shapley
values. The Shapley structure is handled via elementary-symmetric-polynomial
identities of the kernel's generating polynomials, so the 2^n coalition
space is never enumerated.

- new optional extra 'shapleig' (torch/gpytorch/botorch/linear_operator)
  with lazy import and an informative placeholder when not installed
- shapiq/approximator/shapleig/: approximator + flat Hamming GP surrogate +
  self-contained ESP math core (controlled copy of the validated reference
  implementation, kept in sync)
- order-1 SV InteractionValues output (min_order=0, baseline = empty
  coalition value); SV-variance return left as a commented scaffold until
  InteractionValues supports uncertainty information
- tqdm progress bar over the BED iterations
- registered in SV_APPROXIMATORS and the public API; unit tests covering
  output format, determinism, and convergence to ExactComputer ground truth
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.93805% with 50 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/shapiq/approximator/shapleig/shapleig.py 82.23% 27 Missing ⚠️
src/shapiq/approximator/shapleig/_shapley_math.py 92.46% 18 Missing ⚠️
src/shapiq/approximator/shapleig/_surrogate.py 91.37% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

Advueu963 and others added 4 commits June 12, 2026 12:53
- approximate() now delegates to the public approximate_with_variance(),
  which returns the SV estimates together with their marginal posterior
  variances (diagonal of the SV posterior covariance, original game scale);
  verified bit-identical against the reference implementation
- shapleig extra: exact pins relaxed to lower bounds (>=); the bounds are
  the versions the reference implementation was validated against
- float64 is enforced (set/restore) only around GP model construction in
  _surrogate.py: parameters, priors, and constraint initial values are
  created in torch's default dtype before botorch casts to the data dtype,
  and float32 creation changes the fitted hyperparameters and selections
  (verified empirically); everything downstream is float64 via data/params
- infeasibility guards softened to warnings: exhaustive candidates with
  n > 16 warn about cost; a candidate set smaller than the required
  iterations warns and caps the iterations (estimation_budget reports the
  budget actually spent)
- initial design and candidate set now reuse the base class sampler
  (uniform size weights + pairing trick), reset to its seeded initial
  state before each draw, instead of constructing fresh samplers
- docstrings: refit cost note, max_candidates-vs-budget guidance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants