Papers › Counterfactual Shapley Additive Explanations

Counterfactual Shapley Additive Explanations

27 Oct 2021arXiv:2110.14270archive 2025-07-28

Emanuele Albini, Jason Long, Danial Dervovic, Daniele Magazzeni

Feature attributions are a common paradigm for model explanations due to their simplicity in assigning a single numeric score for each input feature to a model. In the actionable recourse setting, wherein the goal of the explanations is to improve outcomes for model consumers, it is often unclear how feature attributions should be correctly used. With this work, we aim to strengthen and clarify the link between actionable recourse and feature attributions. Concretely, we propose a variant of SHAP, Counterfactual SHAP (CF-SHAP), that incorporates counterfactual information to produce a background dataset for use within the marginal (a.k.a. interventional) Shapley value framework. We motivate the need within the actionable recourse setting for careful consideration of background datasets when using Shapley values for feature attributions with numerous synthetic examples. Moreover, we demonstrate the efficacy of CF-SHAP by proposing and justifying a quantitative score for feature attributions, counterfactual-ability, showing that as measured by this metric, CF-SHAP is superior to existing methods when evaluated on public datasets using tree ensembles.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2110.14270")

Code

Syntology Ran 0 of 13 code samples harvested from 2 repositories linked to this paper; 13 have no recorded run.

By repository: official repository: 2 samples from 1 repository, 0 ran; community (archive-listed): 11 samples from 1 repository, 0 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

jpmorganchase/cf-shap officialmentioned on GitHubApache-2.0 report
jpmorganchase/cf-shap-facct22 mentioned on GitHubApache-2.0 report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

13 samples harvested; 0 ran; 0 honoured the contract we drafted; 13 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

13unverified

Licence: 0 of the 13 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 2 repositories linked to this paper, official or community; each sample names its own and says which. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

expand_dims_counterfactuals jpmorganchase/cf-shap/src/cfshap/utils/_utils.py official repository unverified Apache-2.0 (permissive) · 2bb7c5f5b3a4c17c · report
function_cache jpmorganchase/cf-shap/src/cfshap/utils/_python.py official repository unverified Apache-2.0 (permissive) · 3a4957442e0cea29 · report
bold jpmorganchase/cf-shap-facct22/emutils/latex.py community (archive-listed) unverified Apache-2.0 (permissive) · 256d8ce6c60ecba3 · report
duration_to_long_string jpmorganchase/cf-shap-facct22/emutils/human.py community (archive-listed) unverified Apache-2.0 (permissive) · 4af7e8d6e2ed9009 · report
exp jpmorganchase/cf-shap-facct22/emutils/latex.py community (archive-listed) unverified Apache-2.0 (permissive) · 0f57192d632b4c3f · report
is_xp_col jpmorganchase/cf-shap-facct22/explanations.py community (archive-listed) unverified Apache-2.0 (permissive) · 35f417db85063189 · report
latex_config_decorator jpmorganchase/cf-shap-facct22/emutils/latex.py community (archive-listed) unverified Apache-2.0 (permissive) · 411314cff681cc43 · report
replace_nan jpmorganchase/cf-shap-facct22/utils.py community (archive-listed) unverified Apache-2.0 (permissive) · 9c9fe6d665155cf1 · report
safe_mean jpmorganchase/cf-shap-facct22/utils.py community (archive-listed) unverified Apache-2.0 (permissive) · bfffd44741ec05c4 · report
safe_std jpmorganchase/cf-shap-facct22/utils.py community (archive-listed) unverified Apache-2.0 (permissive) · 665b007249dd5e26 · report
skl_binary_wrapper jpmorganchase/cf-shap-facct22/emutils/model/wrappers.py community (archive-listed) unverified Apache-2.0 (permissive) · 42ffb205b177a200 · report
skl_predict_binary jpmorganchase/cf-shap-facct22/emutils/model/wrappers.py community (archive-listed) unverified Apache-2.0 (permissive) · 749ee3ced30b14d9 · report
xps_to_df jpmorganchase/cf-shap-facct22/explanations.py community (archive-listed) unverified Apache-2.0 (permissive) · ac418a20a2bb48f6 · report

Tasks

Counterfactual ExplanationExplainable artificial intelligenceFeature Importance

1 archive task tag without a task page not shown.

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

SHAPk-NN

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections