Permutation, LIME, standard errors and budgets

permutation and lime, then standard errors, stopping and budget planning. Other samplers: Approximate estimation.

Permutation sampling and the LIME surrogate

permutation evaluates every prefix of a random player ordering. antithetic: true (default) adds the reverse ordering: its size-\((n - k)\) prefix complements the size-\(k\) prefix of the first.

Ordering today, Cancel, plan, my, phone, old with prefix today, Cancel; its reverse has prefix old, phone, my, plan, the four other words.

Illustrative. An ordering of the running example and its reverse.

A uniform ordering’s size-\(k\) prefix is a uniform size-\(k\) subset, so prefixes feed mc’s size-stratified aggregation, under any estimand. Prefixes of one ordering are correlated; the standard errors below ignore that.

lime fits the surrogate of Ribeiro et al. (2016). A random subset \(S\) gets weight \(w(S) = \sqrt{\exp(-d(S)^2 / \sigma^2)}\), \(\sigma = 25\), with \(d(S) = 100\,(1 - \sqrt{|S|/n})\), 100 times the cosine distance to the all-present vector. The fit is ridge regression with an unpenalised intercept:

\[\min_{b,\beta}\; \sum_S w(S)\,\bigl(v(S) - b - \beta^\top x_S\bigr)^2 + \alpha \lVert\beta\rVert^2\]

For \(n = 6\): three words give \(d = 29.3\), \(w = 0.50\); five words \(w = 0.94\); none \(w = 0.0003\).

Code for this figure
import matplotlib.pyplot as plt
import numpy as np

from mllm_shap import LimeEstimator

width = LimeEstimator().kernel_width
share = np.linspace(0, 1, 201)
distance = 100 * (1 - np.sqrt(share))
fig, ax = plt.subplots(figsize=(6.4, 3.0))
ax.plot(share, np.sqrt(np.exp(-distance**2 / width**2)), color="#2a78d6")
ax.set(xlabel="share of players present, |S| / n", ylabel="LIME weight w(S)",
       ylim=(0, 1.05))
ax.spines[["top", "right"]].set_visible(False)

LIME kernel with the default width 25

S-shaped curve from 0 with no players to 1 with all, 0.5 near half.

From the formula. Below a fifth of the players the weight is under 0.1: the fit stays near the full prompt. The coefficients are no Shapley values. They depend on kernel and penalty, need not sum to \(v(N) - v(\emptyset)\) and ignore the estimand.

Standard errors

mc estimates \(\hat\phi_i = \sum_l q_l\,(\bar v^{+}_{i,l} - \bar v^{-}_{i,l})\) from the stratum means of What the aggregator computes from partial samples, \(q_l\) the renormalised stratum probabilities. Each size is a simple random sample, so each mean has variance \((s^2 / n_s)(1 - n_s / N_l)\), \(N_l = \binom{n-1}{l}\) (finite-population correction). Strata are independent:

\[\operatorname{Var}(\hat\phi_i) = \sum_l q_l^2 \bigl(\operatorname{Var}\bar v^{+}_{i,l} + \operatorname{Var}\bar v^{-}_{i,l}\bigr).\]

A side with one observation uses the pooled payoff variance. Enumerated strata add no error, so a full table gives zero. A player with no stratum observed on both sides has value 0 and error inf: no estimate, so no interval and no early stop.

Coverage of \(\hat\phi_i \pm 1.96\,\widehat{\mathrm{se}}_i\) (1.96: the 97.5% normal quantile), 2,000 seeds on the test suite’s seven reference games, 25% budget unless stated:

Estimator and error

Coverage of the 95% interval

Reported

mc, formula above

93.3–95.0%

yes

permutation, same formula

60–82%

no

permutation, jackknife over orderings

96–99%; 87–92% at 10%

no

leverage, kernel_banzhaf, sandwich

miscalibrated

no

The jackknife drops one ordering and its reverse at a time. It needs each coalition’s ordering, which the archive lacks.

Stopping

Every check_every coalitions past a floor, sampling stops if the widest interval is at most max_ci_width or the top_k_stable largest players match the last check. The budget stays the cap. On the reference games it saved 0 to 7% against a fixed budget of equal error, so use it to control accuracy, not cost.

Planning a budget

With marginal contributions in a range of width \(r\), error \(\epsilon\) at confidence \(1 - \beta\) needs (Hoeffding’s inequality, union bound over \(n\) players)

\[m \ge \frac{r^2 \ln(2n / \beta)}{2\,\epsilon^2}\]

random orderings (Maleki et al., 2013), each with \(n - 1\) new coalitions. mllm-shap plan evaluates it.

For \(n = 6\), \(r = 1\), \(\epsilon = \beta = 0.05\): \(m \ge \ln 240 / 0.005\), 1,097 orderings or about 5,500 coalitions, against 64 for exact; plan says so. The bound is a worst case; a pilot run’s range tightens it.

References

  • Maleki, S., Tran-Thanh, L., Hines, G., Rahwan, T., Rogers, A. (2013). Bounding the Estimation Error of Sampling-based Shapley Value Approximation. arXiv:1306.4265. https://arxiv.org/abs/1306.4265

  • Ribeiro, M. T., Singh, S., Guestrin, C. (2016). “Why Should I Trust You?”: Explaining the Predictions of Any Classifier. KDD. https://arxiv.org/abs/1602.04938

Further reading