Skip to main content

Stabilizing Estimates of Shapley Values with Control Variates

  • Conference paper
  • First Online:
Explainable Artificial Intelligence (xAI 2024)

Part of the book series: Communications in Computer and Information Science ((CCIS,volume 2154))

Included in the following conference series:

  • 815 Accesses

Abstract

Shapley values are among the most popular tools for explaining predictions of black-box machine learning models. However, their high computational cost motivates the use of sampling approximations, inducing a considerable degree of uncertainty. To stabilize these model explanations, we propose ControlSHAP, an approach based on the Monte Carlo technique of control variates. Our methodology is applicable to any machine learning model and requires virtually no extra computation or modeling effort. On several high-dimensional datasets, we find it can produce dramatic reductions in the variability of Shapley estimates.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

Notes

  1. 1.

    https://github.com/jeremy-goldwasser/ControlSHAP contains our code and experimental results.

References

  1. Aas, K., Jullum, M., Løland, A.: Explaining individual predictions when features are dependent: more accurate approximations to shapley values. Artif. Intell. 298, 103502 (2021)

    Article  MathSciNet  Google Scholar 

  2. Belle, V., Papantonis, I.: Principles and practice of explainable machine learning. Front. Big Data 4, 688969 (2021)

    Article  Google Scholar 

  3. Berger, A., et al.: A comprehensive TCGA pan-cancer molecular study of gynecologic and breast cancers. Cancer Cell 33 (2018)

    Google Scholar 

  4. Breiman, L.: Random forests. Mach. Learn. 45(1), 5–32 (2001)

    Article  Google Scholar 

  5. Campbell, T.W., Roder, H., Georgantas, R.W., III., Roder, J.: Exact shapley values for local and model-true explanations of decision tree ensembles. Mach. Learn. Appl. 9, 100345 (2022)

    Google Scholar 

  6. Charnes, A., Golany, B., Keane, M., Rousseau, J.: Extremal principle solutions of games in characteristic function form: core, Chebychev and Shapley value generalizations. In: Sengupta, J.K., Kadekodi, G.K. (eds.) Econometrics of Planning and Efficiency, pp. 123–133. Springer, Dordrecht (1988). https://doi.org/10.1007/978-94-009-3677-5_7

    Chapter  Google Scholar 

  7. Chen, H., Janizek, J.D., Lundberg, S.M., Lee, S.: True to the model or true to the data? CoRR abs/2006.16234 (2020)

    Google Scholar 

  8. Chen, J., Song, L., Wainwright, M.J., Jordan, M.I.: L-shapley and c-shapley: efficient model interpretation for structured data. CoRR abs/1808.02610 (2018)

    Google Scholar 

  9. Covert, I., Lee, S.: Improving kernelshap: practical shapley value estimation via linear regression. CoRR abs/2012.01536 (2020)

    Google Scholar 

  10. Covert, I., Lundberg, S.M., Lee, S.: Understanding global feature contributions through additive importance measures. CoRR abs/2004.00668 (2020)

    Google Scholar 

  11. Dubey, R., Chandani, A.: Application of machine learning in banking and finance: a bibliometric analysis. Int. J. Data Anal. Tech. Strateg. 14(3) (2022)

    Google Scholar 

  12. Fang, K.T., Kotz, S., Ng, K.W.: Symmetric Multivariate and Related Distributions. Chapman and Hall, Boca Raton (1990)

    Google Scholar 

  13. Ferdous, M., Debnath, J., Chakraborty, N.R.: Machine learning algorithms in healthcare: a literature survey. In: 11th International Conference on Computing, Communication and Networking Technologies, ICCCNT 2020, Kharagpur, India, 1–3 July 2020, pp. 1–6. IEEE (2020)

    Google Scholar 

  14. Ghorbani, A., Zou, J.Y.: Neuron shapley: discovering the responsible neurons. In: Larochelle, H., Ranzato, M., Hadsell, R., Balcan, M., Lin, H. (eds.) Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020, 6–12 December 2020, virtual (2020)

    Google Scholar 

  15. Goli, A., Mohammadi, H.: Developing a sustainable operational management system using hybrid Shapley value and Multimoora method: case study petrochemical supply chain. Environ. Dev. Sustain. 24(9), 10540–10569 (2022). https://doi.org/10.1007/s10668-021-01844-

    Article  Google Scholar 

  16. Hofmann, H.: Statlog (German credit data) (1994)

    Google Scholar 

  17. Hooker, G., Mentch, L., Zhou, S.: Unrestricted permutation forces extrapolation: variable importance requires at least one more model, or there is no free variable importance. Stat. Comput. 31, 1–16 (2021)

    Article  MathSciNet  Google Scholar 

  18. Jethani, N., Sudarshan, M., Covert, I.C., Lee, S., Ranganath, R.: Fastshap: real-time shapley value estimation. In: The Tenth International Conference on Learning Representations, ICLR 2022, Virtual Event, 25–29 April 2022. OpenReview.net (2022)

    Google Scholar 

  19. Kohavi, R.: Census income (1996)

    Google Scholar 

  20. Laugel, T., Lesot, M., Marsala, C., Detyniecki, M.: Issues with post-hoc counterfactual explanations: a discussion. CoRR abs/1906.04774 (2019)

    Google Scholar 

  21. Leisch, F., Weingessel, A., Hornik, K.: On the generation of correlated artificial binary data. In: SFB Adaptive Information Systems and Modelling in Economics and Management Science, vol. 20 (1970)

    Google Scholar 

  22. Lundberg, S.M., et al.: From local explanations to global understanding with explainable AI for trees. Nat. Mach. Intell. 2(1), 56–67 (2020)

    Article  Google Scholar 

  23. Lundberg, S.M., Lee, S.: A unified approach to interpreting model predictions. In: Guyon, I., et al. (eds.) Advances in Neural Information Processing Systems 30: Annual Conference on Neural Information Processing Systems 2017, 4–9 December 2017, Long Beach, CA, USA, pp. 4765–4774 (2017)

    Google Scholar 

  24. Mandalapu, V., Elluri, L., Vyas, P., Roy, N.: Crime prediction using machine learning and deep learning: a systematic review and future directions. IEEE Access 11, 60153–60170 (2023)

    Article  Google Scholar 

  25. Mitchell, R., Cooper, J., Frank, E., Holmes, G.: Sampling permutations for shapley value estimation. J. Mach. Learn. Res. 23, 43:1–43:46 (2022)

    Google Scholar 

  26. Moro, S., Cortez, P., Rita, P.: A data-driven approach to predict the success of bank telemarketing. Decis. Support Syst. 62, 22–31 (2014)

    Article  Google Scholar 

  27. Narayanam, R., Narahari, Y.: Determining the top-k nodes in social networks using the shapley value. In: Padgham, L., Parkes, D.C., Müller, J.P., Parsons, S. (eds.) 7th International Joint Conference on Autonomous Agents and Multiagent Systems (AAMAS 2008), Estoril, Portugal, 12–16 May 2008, vol. 3, pp. 1509–1512. IFAAMAS (2008)

    Google Scholar 

  28. Oates, C.J., Girolami, M., Chopin, N.: Control functionals for Monte Carlo integration. J. R. Stat. Soc. Ser. B Stat. Methodol. 79(3), 695–718 (2017)

    Article  MathSciNet  Google Scholar 

  29. Ribeiro, M.T., Singh, S., Guestrin, C.: “why should I trust you?”: explaining the predictions of any classifier. In: Krishnapuram, B., Shah, M., Smola, A.J., Aggarwal, C.C., Shen, D., Rastogi, R. (eds.) Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, San Francisco, CA, USA, 13–17 August 2016, pp. 1135–1144. ACM (2016)

    Google Scholar 

  30. Rudin, C.: Stop explaining black box machine learning models for high stakes decisions and use interpretable models instead. Nat. Mach. Intell. 1(5), 206–215 (2019)

    Article  Google Scholar 

  31. Shapley, L.: A value for n-person games (1952)

    Google Scholar 

  32. Song, E., Nelson, B.L., Staum, J.: Shapley effects for global sensitivity analysis: theory and computation. SIAM/ASA J. Uncertain. Quantification 4(1), 1060–1083 (2016)

    Article  MathSciNet  Google Scholar 

  33. Strumbelj, E., Kononenko, I.: An efficient explanation of individual classifications using game theory. J. Mach. Learn. Res. 11, 1–18 (2010)

    MathSciNet  Google Scholar 

  34. Strumbelj, E., Kononenko, I.: Explaining prediction models and individual predictions with feature contributions. Knowl. Inf. Syst. 41(3), 647–665 (2014)

    Article  Google Scholar 

  35. Sundararajan, M., Najmi, A.: The many shapley values for model explanation. In: Proceedings of the 37th International Conference on Machine Learning, ICML 2020, 13–18 July 2020, Virtual Event. Proceedings of Machine Learning Research, vol. 119, pp. 9269–9278. PMLR (2020)

    Google Scholar 

  36. Tibshirani, R.: Regression shrinkage and selection via the lasso. J. Roy. Stat. Soc. Ser. B (Methodol.) 58(1), 267–288 (1996)

    Google Scholar 

  37. Tomita, T.M., et al.: Sparse projection oblique randomer forests. J. Mach. Learn. Res. 21(1), 4193–4231 (2020)

    MathSciNet  Google Scholar 

  38. Verma, S., Dickerson, J.P., Hines, K.: Counterfactual explanations for machine learning: a review. CoRR abs/2010.10596 (2020)

    Google Scholar 

  39. Zhou, Y., Zhou, Z., Hooker, G.: Approximation trees: statistical stability in model distillation. CoRR abs/1808.07573 (2018)

    Google Scholar 

  40. Zhou, Z., Hooker, G., Wang, F.: S-LIME: stabilized-lime for model explanation. In: Zhu, F., Ooi, B.C., Miao, C. (eds.) KDD 2021: The 27th ACM SIGKDD Conference on Knowledge Discovery and Data Mining, Virtual Event, Singapore, 14–18 August 2021, pp. 2429–2438. ACM (2021)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Jeremy Goldwasser .

Editor information

Editors and Affiliations

Ethics declarations

Disclosure of Interests

We have no competing interests to disclose.

Appendices

Appendix

A Exact Shapley Values

1.1 A.1 Shapley Value, Assuming Feature Independence

Proof

Assume features are sampled independently in the value function. Consider a second-order Taylor approximation to f at x:

$$\begin{aligned} g(x') := f(x) + (x'-x)^T \nabla f(x) + \frac{1}{2}(x'-x)^T \nabla ^2 f(x) (x'-x). \end{aligned}$$

Let \(J = \nabla f(x)\), \(H = \nabla ^2 f(x)\), \(\varSigma =\text {Cov}(X)\), and \(\sigma ^2_{k\ell }=\text {Cov}(X_k, X_\ell )\). The Shapley value function is

$$\begin{aligned} v_x(S) &= E[g(X')|X'_S = x_S]\\ &= f(x) + E[(x'-x)|X'_S=x_S]^T \nabla f(x) \\ &\qquad \qquad + \frac{1}{2}E\Big [(x'-x)^T \nabla ^2 f(x) (x'-x)|X'_S=x_S\Big ]\\ &= f(x) + (\mu _{S^C} - x_{S^C})^T J_{S^C}\\ &\qquad \qquad + \frac{1}{2}E\Big [(x_{S^C}'-x_{S^C})^T \nabla ^2 f(x)_{{S^C}{S^C}} (x_{S^C}'-x_{S^C})\Big ], \end{aligned}$$

where the quadratic term is equal to

$$\begin{aligned} &tr(H_{{S^C}{S^C}}\varSigma _{{S^C}{S^C}}) + (\mu _{S^C}- x_{S^C})^T H_{{S^C}{S^C}}(\mu _{S^C}- x_{S^C})\\ = &\sum _{k\in {S^C}}\sum _{\ell \in {S^C}} H_{k\ell }\Big (\sigma ^2_{k\ell } + (\mu _k - x_k)(\mu _\ell - x_\ell )\Big )\\ = &H_{jj}(\sigma ^2_{jj} + (\mu _j-x_j)^2). \end{aligned}$$

Recall \(\displaystyle \phi _j(x) := \frac{1}{d} \sum _{S \subseteq [d]\backslash \{j\}} {d-1\atopwithdelims ()|S|}^{-1} \big (v_x(S \cup \{j\}) - v_x(S)\big )\). The difference in value functions is

Define the Shapley weight \(w_S = \frac{1}{d}{d-1\atopwithdelims ()|S|}^{-1}\).

(10)

Noting subsets of equal size have the same Shapley weight, we can easily show \(\displaystyle \sum _{S \subseteq [d]\backslash \{j\}}w_S = 1\).

$$\begin{aligned} \begin{aligned} \sum _{S \subseteq [d]\backslash \{j\}}w_S &= \sum _{S \subseteq [d]\backslash \{j\}} \frac{1}{d}{d-1\atopwithdelims ()|S|}^{-1}\\ &= \sum _{a=0}^{d-1} {d-1\atopwithdelims ()a} \frac{1}{d}{d-1\atopwithdelims ()a}^{-1} = \sum _{a=0}^{d-1}\frac{1}{d}=1 \end{aligned} \end{aligned}$$
(11)

With a bit more arithmetic, we can show \(\displaystyle \sum _{S \subseteq [d]\backslash \{j, k\}}w_S = \frac{1}{2}\).

$$\begin{aligned} \begin{aligned} \sum _{S \subseteq [d]\backslash \{j, k\}}w_S &= \sum _{a=0}^{d-2} {d-2\atopwithdelims ()a} \frac{1}{d}{d-1\atopwithdelims ()a}^{-1}\\ &= \sum _{a=0}^{d-2} \frac{(d-2)!}{a!(d-a-2)!}\frac{a!(d-a-1)!}{d!}\\ &= \sum _{a=0}^{d-2} \frac{d-a-1}{d(d-1)}\\ &= \frac{1}{d(d-1)}\Big [d(d-1) - \sum _{a=0}^{d-2}(a+1) \Big ]\\ &= \frac{1}{d(d-1)}\Big [d(d-1) - \frac{d(d-1)}{2} \Big ] = \frac{1}{2}. \end{aligned} \end{aligned}$$
(12)

Plugging the results of 11 and 12 into 10 yields the final expression for the Shapley value:

   \(\square \)

1.2 A.2 Shapley Value, Correlated Features

Consider the linear model \(g(x') = \beta ^T x' + b\), where \(x' \sim \mathcal {N}(\mu , \varSigma )\). (For our problem, \(\beta = \nabla f(x)\) and \(b = f(x)\).)

Let \(P_S\) be the projection matrix selecting set S; define \(R_S = P_{\bar{S}}^T P_{\bar{S}} \varSigma P_S^T (P_S \varSigma P_S^T)^{-1} P_S\) and \(Q_S = P_S^T P_S\). We consider the set of permutations of [d], each of which indexes a subset S as the features that appear before j. Averaging over all such permutations, the Shapley values of g(x) [1, 7, 23] are

$$\begin{aligned} \phi _j(x') &= \beta \underbrace{\left[ \frac{1}{d!} \sum _m ([Q_{\{S^m \cup j\}^C} - R_{S^m \cup j}]- [Q_{\{S^m\}^C} - R_{S^m}])\right] }_{C_j} \mu \\ &\qquad \qquad + \beta \underbrace{\left[ \frac{1}{d!} \sum _m ([Q_{S^m \cup j} + R_{S^m \cup j}] - [Q_{S^m} + R_{S^m}]) \right] }_{D_j} x'. \end{aligned}$$

Lastly, we observe that \(C_j = -D_j\). For each subset S, the R terms cancel out; \(Q_{S^C} + Q_S = I_d\), so \(Q_{\{S\cup j\}^C} - Q_{S^C} = -(Q_{S\cup j} - Q_S)\). This yields our expression for the dependent Shapley value:

$$\begin{aligned} \phi _j^g(x) = \beta ^T D_j (x - \mu ). \end{aligned}$$

B Comprehensive Results

We display results across all 5 datasets and 3 machine learning predictors. All datasets were binary classification problems, so we used the same models to fit them. For logistic regression and random forest, we used the sklearn implementation with default hyperparameters. For the neural network, we fit a two-layer MLP in Pytorch with 50 neurons in the hidden layer and hyperbolic tangent activation functions.

Figure 6 displays the variance reductions of our ControlSHAP methods in the four settings: Independent vs Dependent Features, and Shapley Sampling vs KernelSHAP. The error bars span the 2th to 7th percentiles of the variance reductions for 40 held-out samples.

Figure 7 compares the average number of changes in rankings between the original and ControlSHAP Shapley estimates. Specifically, we look the Shapley estimates obtained via KernelSHAP, assuming correlated features.

Fig. 6.
figure 6

Variance Reductions

Fig. 7.
figure 7

Average Number of Rank Changes, with and without ControlSHAP’s adjustment via Control Variates (CV).

C Anticipated Correlation

Figure 8 compares the observed and anticipated variance reductions, across two combinations of dataset and predictor. Recall that the variance reduction of the control variate estimate for \(\phi _j(x)\) is \(\rho ^2(\hat{\phi }_j(x)^\text {model}, \hat{\phi }_j(x)^\text {approx})\), where \(\rho \) is the Pearson’s correlation coefficient. We compute the sample correlation coefficient of the Shapley values on sample x as follows:

$$\begin{aligned} \hat{\rho } := \frac{\widehat{\text {Cov}}(\hat{\phi }_j(x)^\text {model}, \hat{\phi }_j(x)^\text {approx})}{\sqrt{\widehat{\text {Var}}(\hat{\phi }_j(x)^\text {model})\widehat{\text {Var}}(\hat{\phi }_j(x)^\text {approx})}} \end{aligned}$$

We average this across the 50 iterations to obtain a single estimate for the correlation \(\hat{\rho }\). The plots display the median and error bars for \(\hat{\rho }^2(\hat{\phi }_j(x)^\text {model}, \hat{\phi }_j(x)^\text {approx})\) across 40 samples. Once again, the error bars span the 2th to 7th percentiles.

Fig. 8.
figure 8

Anticipated vs Observed Variance Reduction

D Comparing KernelSHAP Variance Estimators

Section 4.2 of the paper details methods for computing the variance and covariance between KernelSHAP estimates. Bootstrapping and the least squares covariance produce extremely similar estimates. In turn, these produce ControlSHAP estimates that reduce variance by roughly the same amount, as shown in Fig. 9. This indicates that both methods are appropriate choices.

In contrast, we were not able to get the grouped method to reliably work. Its variance estimates were somewhat erratic, as they are drawn from a heavy-tailed \(\chi ^2\) distribution (Fig. 10). As a result, its ControlSHAP estimates were occasionally more variable than the original KernelSHAP values themselves.

Fig. 9.
figure 9

Variance reductions of ControlSHAP across 40 samples with bootstrapped and least-squares estimates of KernelSHAP variance and covariance. Shapley estimates computed assuming independent features.

Fig. 10.
figure 10

Correlation between model and Taylor approximation, grouped and least squares. Same input and feature across 50 iterations, with logistic regression on the bank dataset.

Rights and permissions

Reprints and permissions

Copyright information

© 2024 The Author(s), under exclusive license to Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Goldwasser, J., Hooker, G. (2024). Stabilizing Estimates of Shapley Values with Control Variates. In: Longo, L., Lapuschkin, S., Seifert, C. (eds) Explainable Artificial Intelligence. xAI 2024. Communications in Computer and Information Science, vol 2154. Springer, Cham. https://doi.org/10.1007/978-3-031-63797-1_21

Download citation

  • DOI: https://doi.org/10.1007/978-3-031-63797-1_21

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-031-63796-4

  • Online ISBN: 978-3-031-63797-1

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics