1. Introduction
The original KernelSHAP paper by Lundberg and Lee [
1] from 2017 was a landmark success for interpretable machine learning. Its primary achievement was making the Shapley value [
2] — a theoretically optimal but computationally intractable [
3,
4,
5] concept from cooperative game theory [
6] — practical for explaining machine learning models. Lundberg and Lee [
1] discovered that the exact Shapley values for a prediction could be recovered as the solution to a specially weighted least squares regression problem. By sampling a manageable number of coalitional inputs and solving this approximate regression, KernelSHAP provided a single, consistent metric for feature importance. The accompanying open-source shap library SHAP [
1] fueled its widespread use, making it a predominant standard for model interpretation, particularly in the model-agnostic setting.
The follow-up work on Unbiased KernelSHAP by Covert and Lee [
7] represents a success in methodological rigor. It addresses the problem that the original KernelSHAP algorithm has not been proven to be unbiased and does not provide uncertainty estimates. While not as publicly visible as the initial breakthrough, this refinement solidified SHAP’s foundation as a robust, statistically sound tool.
According to Lundberg and Lee [
1], KernelSHAP was developed without knowledge of prior articles on cooperative game theory like Charnes et al. [
8] and Ruiz et al. [
9], who decades earlier had already derived the precise weighting scheme that makes a least-squares regression yield the Shapley value when complete data is available. This outlines a fascinating case of parallel innovation across disciplines. Cooperative game theory, with the Shapley value [
2] as its most important solution concept, had long been a mature and applied field providing rigorous solutions to real-world problems of fair division and coalitional analysis, from allocating airport landing fees among airlines based on runway use [
10] to measuring the voting power of political blocs in a legislature [
11,
12,
13]. Yet, the field of machine learning, increasingly reliant on inscrutable black-box models, had not seen its own predictions as precisely such a system — where input features act as cooperating agents whose joint effort produces a model’s output. Lundberg and Lee’s pivotal contribution [
1] was to bridge this conceptual gap. They recognized that the abstract "game" defined by a model’s prediction function was a natural domain for Shapley’s theory. By doing so, they inadvertently reinvented a specific computational tool — the weighted least-squares approximation — from the game theory literature, but with a transformative new purpose: not to analyze economic coalitions, but to explain the inner logic of artificial intelligence.
Whereas KernelSHAP [
1] and its unbiased variant [
7] are very widely used, the methods from Benati et al. [
14] — which are equally based on the least squares formulation of the Shapley value — have received comparatively little attention. This article represents, to our knowledge, their first application in explainable artificial intelligence. We adapt the ideas from Benati et al. [
14] as general TU game approximation algorithms, terming their weighted sampling strategy LSS (Least Squares Sampling). Regarding their proposal for stratification, we differentiate S-LSS, an algorithm without sample reuse across strata, from SRS-LSS, an algorithm with sample reuse across strata suggested in Benati et al. [
14].
The objective of this paper is neither to introduce a novel Shapley value estimator nor to perform a broad comparison of approximation algorithms. Instead, the contribution of this work is a detailed structural, theoretical, and algorithmic analysis of the methods LSS, S-LSS and SRS-LSS from Benati et al. [
14]. We compare the variances of the LSS and S-LSS estimators in detail. We point out how sample reuse across strata may introduce non-zero covariance terms between strata for SRS-LSS. We prove that LSS and UKS approximate the same underlying problem, thereby only differing in their respective sampling strategies. Finally, we test how the unbiased Shapley estimators LSS, S-LSS and SRS-LSS perform in comparison to KernelSHAP and UKS for both classical cooperative games and real-world applications from interpretable machine learning.
The remainder of this article is structured as follows. In
Section 2, we summarize basic ideas from cooperative game theory, including linear solution concepts and the Shapley value, and introduce the BShap (Baseline Shapley) model for interpretable machine learning.
Section 3 briefly reviews Monte Carlo methods, along with stratified sampling and importance sampling for variance reduction. A summary of results on approximating linear solution concepts by means of importance sampling on the coalition space from our previous work [
15] is presented in
Section 4. The central developments of this paper are detailed in
Section 5. We formally introduce the LSS, S-LSS and SRS-LSS estimators, compare variances of LSS and S-LSS, investigate the emergence of non-zero covariance terms between strata for SRS-LSS and clarify the similarities and differences between LSS and UKS. The empirical performance of the algorithms introduced in
Section 5 is analyzed in
Section 6 using two types of cooperative games and three real-world explainability scenarios, thereby numerically substantiating our previous analytical claims. The paper concludes in
Section 7 with a summary and recommendations.
4. Approximating Linear Solution Concepts via Importance Sampling
The exact calculation of a linear solution concept, i.e., (
1), for a TU game normally requires summing up terms whose number grows exponentially in the number of players
n. Therefore, approximation algorithms are needed to estimate these values in real-world situations, especially in the context of applications in interpretable machine learning [
1,
17,
18,
19] where one can typically not exploit any special structure of the underlying game for computing Shapley values exactly. In this section, we briefly summarize some ideas from [
14] and the general framework for importance sampling on the coalition space for linear solution concepts which we recently proposed in [
15] and will apply in
Section 5.
Benati et al. [
14] consider a uniform sampling strategy on the coalition space for approximating linear solution concepts, i.e. they simply adopt the uniform distribution
. Let us regard it as the crude Monte Carlo method on the coalition space. Although sampling subsets from the uniform distribution is both straightforward and unbiased, it is obviously not an optimal — or even recommendable — sampling strategy for all linear solution concepts or problem settings. For example, when approximating the Shapley value by sampling coalitions using (), small or large coalitions obtain larger weights resulting in a strong influence on the estimator. However, when sampling uniformly from the coalition space, they may extract only a few samples resulting in a less accurate estimator.
To enable more efficient sampling, we apply the importance sampling technique from Sub
Section 3.3. By appropriately reweighting the estimator, importance sampling allows us to draw samples from a non-uniform, user-defined distribution while maintaining an unbiased estimate of the underlying linear solution concept.
Theorem 1.
[15] For all , let
be a probability distribution and with be a sample of size τ generated by sampling with replacement according to . Then,
is an importance sampling estimator of the linear solution concept .
The following proposition connects our importance sampling estimator from Theorem 1 established in Pollmann and Staudacher [
15] to a finding from Benati et al. [
14], p. 95.
Proposition 1. The importance sampling estimator from Theorem 1 has the following properties:
- (a)
- (b)
- (c)
It is consistent in probability, i.e.,
We note that Theorem 1 and Proposition 1 subsume both the crude Monte Carlo method (setting
) and stratified sampling. The latter is covered because any stratum estimator for a linear solution concept can be written in the form of (
16), allowing direct application of these results.
6. Empirical Results
We validate our results by applying the algorithms introduced in Sub
Section 5.2 to approximate Shapley values for airport games, weighted voting games, and three real-world interpretable machine learning problems.
The algorithms introduced in Sub
Section 5.2 were implemented in Python. Both the implementations and test problems can be freely accessed via the first author’s GitHub repository
We consistently assume that all players’ Shapley values must be estimated. Although not universal, this is common in explainable machine learning, where one seeks to explain a prediction using all features.
Before proceeding, we note that each algorithm uses different parameters to determine the number of sampled coalitions and thus, evaluations of the characteristic function v. For fair comparisons, we introduce a unified sample budget T, ensuring each algorithm performs T evaluations of v, up to negligible rounding errors.
The overall sample budget
T, introduced above, sets the total number of
v evaluations per algorithm. We now express the parameters of each algorithm from Sub
Section 5.2 in terms of
T.
For LSS (Algorithm 1) and UKS (see the end of Sub
Section 5.2), this is a one-to-one mapping, i.e.,
. Note that we ignore the single evaluation of
v needed for calculating the initial term
, since it is negligible in comparison to the rounding errors of other algorithms, especially for large
T.
S-LSS (Algorithm 2) divides the sample space based on
distinct values of
s, for each
. We use the heuristically motivated proportional sample allocation from (
58) to obtain
Finally, SRS-LSS (Algorithm 3) divides the sample space into
distinct sets. Thus, for simplicity, noting that alternative sample allocation schemes across strata may provide better results, we set
We conclude that the deviation from the true total sample budget T is 1 for LSS and UKS, while the upper bounds of their deviations are given by for S-LSS and for SRS-LSS. We consider these deviations to be negligible in our subsequent analysis, in particular for large T.
Note that for SRS-LSS (Algorithm 3), it is not guaranteed that the algorithm runs successfully in the sense that every stratum receives at least one sample, compare Proposition 4. In our mean squared error comparisons, we mandate for any that at least half of all runs must be successful for the results to be displayed in the final figure.
With these definitions established, we proceeded with our experiments.
Figure 5 confirms the theoretical variances of LSS and S-LSS presented in Propositions 2 and 3, respectively. Moreover, it underscores our results from Theorem 2, where we demonstrated that one or the other algorithm might achieve a smaller variance, depending on the underlying cooperative game. Furthermore, we validate that LSS and UKS perform as expected with respect to the theoretical variances presented in Propositions 2 and 11 as
Figure 5 clearly illustrates that the derived theoretical variances are accurate and that, depending on the specific problem, either LSS or UKS may slightly outperform the other, as one sampling strategy might be better suited to the given task than the other method, see Theorem 4.
As for mean squared error comparisons, we first look at an airport game with 100 players specified in Castro et al. [
31] and compare the approximation methods from Sub
Section 5.2 in
Figure 6. Note that the graph for SRS-LSS begins only at a sample size of 50,000, as Proposition 4 fails too frequently with smaller sample budgets. With
players, guaranteeing at least one sample per stratum becomes more challenging.
Figure 8 compares mean squared errors for our Monte Carlo estimators from Sub
Section 5.2 for a weighted voting game with 150 players and uniformly distributed weights, which was previously employed in the software EPIC [
22,
23]. It can be found on the GitHub page of the second author via
https://github.com/jhstaudacher/EPIC/blob/master/test_cases/uniform/uniform.n150.q35951.csv. Note that the graph for SRS-LSS begins only at a sample size of 150,000, as Proposition 4 fails too frequently with smaller sample budgets. With
players, guaranteeing at least one sample per stratum becomes even more challenging than in the airport game from
Figure 6.
Figure 9 uses the standard
diabetes dataset (442 patients, 10 baseline features) where the target is disease progression after one year. We train a Gradient Boosting Regressor and evaluate the approximation methods from Sub
Section 5.2 by their mean squared error against exact reference Shapley values.
In
Figure 10, the
California housing dataset (20,640 entries, 8 features) predicts median house value in hundreds of thousands of dollars. Using an MLP Regressor, we compare approximation methods by their mean squared error on Shapley value estimation against exact references.
Figure 11 uses the classic
wine dataset (178 instances, 13 features, 3 wine classes). We train a Random Forest Classifier and evaluate the approximation methods from Sub
Section 5.2 via mean squared error in estimating Shapley values for predicting the
probability of class 0 only.
Let us summarize the comparisons of mean squared errors of all algorithms for approximating the Shapley value from Sub
Section 5.2 in
Figure 6,
Figure 7,
Figure 8,
Figure 9,
Figure 10 and
Figure 11 succinctly. As expected, LSS and UKS perform more or less equally for all six test problems. SRS-LSS outperforms the other three provably unbiased algorithms LSS, S-LSS and UKS for all test problems. This observation is consistent with the results shown in
Figure 1 in Benati et al. [
14], where only LSS and SRS-LSS were compared. Therefore, we conclude that the covariance terms established in Theorem 3 do not significantly affect the overall variances of individual players’ Shapley value estimators negatively. S-LSS performs worst for five test problems with the notable exception of the airport game with 100 players in
Figure 6 where S-LSS is even faster than KernelSHAP (KS). Not surprisingly, KS is consistently faster than UKS and LSS. For the three large cooperative games in
Figure 6,
Figure 7 and
Figure 8 SRS-LSS converges faster than KS, whereas that comparison reverses for the machine learning tasks in
Figure 9,
Figure 10 and
Figure 11.
7. Summary, Conclusions and Outlook
The celebrated KernelSHAP approach by Lundberg and Lee [
1] as well as its later refinement Unbiased KernelSHAP (UKS) proposed by Covert and Lee [
7] compute the Shapley value as a least squares optimization problem. While these two algorithms are extremely well established in the machine learning community, the methods from the paper by Benati et al. [
14] — which are also based on the least square formula for the Shapley value — have received fairly little attention. To our knowledge, we are the first to apply them in the context of explainable artificial intelligence. We formulate the ideas from Benati et al. [
14] as approximation algorithms for general TU games. We refer to their weighted sampling strategy as LSS (Least Square Sampling). As for their approach towards stratification, we distinguish S-LSS with no reuse of samples across strata and SRS-LSS with sample reuse across strata as proposed in Benati et al. [
14].
As the result of our thorough and detailed analysis of LSS, S-LSS and SRS-LSS, we presented three key findings.
First, in Proposition 5, we showed that S-LSS as proposed in [
14] is not a valid stratified variant of LSS in the sense of the definition provided Sub
Section 3.2,i.e., for S-LSS the strata overlap. Therefore, we demonstrated that S-LSS might reduce the variance of the obtained estimator, but it could also lead to an increase in comparison to LSS, see Theorem 2.
Second, in Theorem 3, we showed that the SRS-LSS approach proposed by Benati et al. [
14] introduces covariance terms between stratum estimators, making its theoretical variance difficult to analyze. Although empirical results suggest that the variance is significantly reduced in comparison to LSS and S-LSS, a theoretical analysis remains an open research question.
Third, in Theorem 4, we established that LSS and UKS are importance sampling estimators in the sense of Theorem 1, addressing the same underlying problem but differing in their respective sampling strategies. Therefore, neither LSS nor UKS is superior over the other one. Which algorithm’s variance is smaller depends on the underlying problem and whether the respective sampling strategy is suitable for this problem or not.
As noted in the introduction, this paper’s aim is neither to propose a new Shapley value estimator nor to compare numerous approximation algorithms. Rather, the focus is on providing structural, theoretical, and algorithmic insight into the methods from Benati et al. [
14]. While antithetic sampling — as discussed, for instance, in [
32] — could be integrated into the SRS-LSS algorithm, this would have vastly exceeded the scope of this study. In the future, it could be worthwhile to investigate whether there are algorithmic approaches comparable to sophisticated stratification strategies [
28,
33,
34] which could be successfully incorporated to enhance the performance of SRS-LSS. Definitely, our theoretical and numerical results suggest that the SRS-LSS estimator — which is unbiased — justifies more attention. Another, perhaps even more pressing question, is why SRS-LSS outperforms KernelSHAP for weighted voting games and airport games while KernelSHAP exhibits superior performance for our test problems from interpretable machine learning. We have yet to identify the properties of the characteristic function responsible for this phenomenon.
Figure 1.
Let
be a cooperative game with
and
,
,
, and
. The
player 1 and
player 2 axes should be interpreted in a discrete way such that 0 denotes the exclusion and 1 specifies the inclusion of a player. The blue plane is the solution to problem (
20) with
m being defined as (
25) and
being obtained from (
26). As a result, the coefficients defining this plane are the Shapley values of the game
, i.e.,
, and
.
Figure 1.
Let
be a cooperative game with
and
,
,
, and
. The
player 1 and
player 2 axes should be interpreted in a discrete way such that 0 denotes the exclusion and 1 specifies the inclusion of a player. The blue plane is the solution to problem (
20) with
m being defined as (
25) and
being obtained from (
26). As a result, the coefficients defining this plane are the Shapley values of the game
, i.e.,
, and
.
Figure 2.
Theoretical variance comparison of LSS and S-LSS evaluated on the weighted voting game defined by (
7). The sample budget is
, and the sample sizes of S-LSS are distributed according to (
58) with ceiling operations applied whenever the result is not an integer. The crosses denote the mean variance across all players’ Shapley values, while the dots specify the variance of
.
Figure 2.
Theoretical variance comparison of LSS and S-LSS evaluated on the weighted voting game defined by (
7). The sample budget is
, and the sample sizes of S-LSS are distributed according to (
58) with ceiling operations applied whenever the result is not an integer. The crosses denote the mean variance across all players’ Shapley values, while the dots specify the variance of
.
Figure 3.
The different sampling distributions of LSS and UKS for .
Figure 3.
The different sampling distributions of LSS and UKS for .
Figure 4.
Theoretical variance comparison of LSS and UKS evaluated the weighted voting games defined by (
7). The number of evaluations of
v is
. The crosses represent the mean variance across all players’ Shapley values, while the dots denote the variance for player
.
Figure 4.
Theoretical variance comparison of LSS and UKS evaluated the weighted voting games defined by (
7). The number of evaluations of
v is
. The crosses represent the mean variance across all players’ Shapley values, while the dots denote the variance for player
.
Figure 5.
Empirical variance validation of
obtained via LSS, S-LSS and UKS evaluated on the weighted voting games defined by (
7). The overall sample budget is
. The crosses represent the theoretical variances, while the dots denote the empirical variances. The empirical variances were obtained over 5000 runs.
Figure 5.
Empirical variance validation of
obtained via LSS, S-LSS and UKS evaluated on the weighted voting games defined by (
7). The overall sample budget is
. The crosses represent the theoretical variances, while the dots denote the empirical variances. The empirical variances were obtained over 5000 runs.
Figure 6.
Empirical mean squared error comparison of obtained via LSS, S-LSS, SRS-LSS, KS and UKS evaluated on an airport game with 100 players. The mean squared errors were averaged over 250 runs.
Figure 6.
Empirical mean squared error comparison of obtained via LSS, S-LSS, SRS-LSS, KS and UKS evaluated on an airport game with 100 players. The mean squared errors were averaged over 250 runs.
Figure 7.
Empirical mean squared error comparison of obtained via LSS, S-LSS, SRS-LSS, KS and UKS evaluated on a weighted voting game with 50 players. The mean squared errors were averaged over 250 runs.
Figure 7.
Empirical mean squared error comparison of obtained via LSS, S-LSS, SRS-LSS, KS and UKS evaluated on a weighted voting game with 50 players. The mean squared errors were averaged over 250 runs.
Figure 8.
Empirical mean squared error comparison of obtained via LSS, S-LSS, SRS-LSS, KS and UKS evaluated on a weighted voting game with 150 players. The mean squared errors were averaged over 250 runs.
Figure 8.
Empirical mean squared error comparison of obtained via LSS, S-LSS, SRS-LSS, KS and UKS evaluated on a weighted voting game with 150 players. The mean squared errors were averaged over 250 runs.
Figure 9.
Empirical mean squared error comparison of obtained via LSS, S-LSS, SRS-LSS, KS and UKS evaluated on the diabetes example. The mean squared errors were averaged over 250 runs.
Figure 9.
Empirical mean squared error comparison of obtained via LSS, S-LSS, SRS-LSS, KS and UKS evaluated on the diabetes example. The mean squared errors were averaged over 250 runs.
Figure 10.
Empirical mean squared error comparison of obtained via LSS, S-LSS, SRS-LSS, KS and UKS evaluated on the California housing example. The mean squared errors were averaged over 250 runs.
Figure 10.
Empirical mean squared error comparison of obtained via LSS, S-LSS, SRS-LSS, KS and UKS evaluated on the California housing example. The mean squared errors were averaged over 250 runs.
Figure 11.
Empirical mean squared error comparison of obtained via LSS, S-LSS, SRS-LSS, KS and UKS evaluated on the wine example. The mean squared errors were averaged over 250 runs.
Figure 11.
Empirical mean squared error comparison of obtained via LSS, S-LSS, SRS-LSS, KS and UKS evaluated on the wine example. The mean squared errors were averaged over 250 runs.
Table 1.
Population and estimator variances for all strata of the S-LSS estimator.
Table 1.
Population and estimator variances for all strata of the S-LSS estimator.
| s |
j |
elements |
population var. |
estimator var. |
| 1 |
1 |
|
0 |
0 |
| 1 |
2 |
|
0 |
0 |
| 1 |
3 |
|
0 |
0 |
| 2 |
1 |
|
0 |
0 |
| 2 |
2 |
|
|
|
| 2 |
3 |
|
|
|
Table 2.
All valid realizations of the sample (order ignored) when , together with their respective probabilities as well the corresponding resulting values of , , and . The last row shows the expected values over all valid realizations, i.e., conditioned on .
Table 2.
All valid realizations of the sample (order ignored) when , together with their respective probabilities as well the corresponding resulting values of , , and . The last row shows the expected values over all valid realizations, i.e., conditioned on .
| #permutations |
|
|
elements of
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
|
|
|
|
0 |
0 |
0 |
|
|
|
|
|
1 |
|
|
|
|
|
0 |
0 |
0 |
|
|
|
|
1 |
|
|
|
|
|
|
1 |
|
|
|
|
|
|
|
|
|