{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/counterfactual-shapley-additive-explanations","title":"Counterfactual Shapley Additive Explanations","arxiv_id":"2110.14270","date":"2021-10-27","proceeding":null,"authors":["Emanuele Albini","Jason Long","Danial Dervovic","Daniele Magazzeni"],"abstract":"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.","url_abs":"https://arxiv.org/abs/2110.14270v4","url_pdf":"https://arxiv.org/pdf/2110.14270v4.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"counterfactual-shapley-additive-explanations","repo_url":"https://github.com/jpmorganchase/cf-shap","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"counterfactual-shapley-additive-explanations","repo_url":"https://github.com/jpmorganchase/cf-shap-facct22","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[{"task_slug":"counterfactual-explanation","task_name":"Counterfactual Explanation"},{"task_slug":"explainable-artificial-intelligence","task_name":"Explainable artificial intelligence"},{"task_slug":"feature-importance","task_name":"Feature Importance"},{"task_slug":null,"task_name":"counterfactual"}],"methods":[{"method_slug":"shap","method_name":"SHAP"},{"method_slug":"k-nn","method_name":"k-NN"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2110.14270","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2110.14270"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/jpmorganchase/cf-shap","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/jpmorganchase/cf-shap-facct22","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"unverified":13},"by_repo_kind":{"official":{"samples":2,"ran":0,"repositories":1},"listed":{"samples":11,"ran":0,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"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"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"256d8ce6c60ecba3","entry":"bold","repo":"jpmorganchase/cf-shap-facct22","repo_kind":"listed","path":"emutils/latex.py","file_url":"https://github.com/jpmorganchase/cf-shap-facct22/blob/HEAD/emutils/latex.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"256d8ce6c60ecba3"}},{"code_sha256_prefix":"4af7e8d6e2ed9009","entry":"duration_to_long_string","repo":"jpmorganchase/cf-shap-facct22","repo_kind":"listed","path":"emutils/human.py","file_url":"https://github.com/jpmorganchase/cf-shap-facct22/blob/HEAD/emutils/human.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"4af7e8d6e2ed9009"}},{"code_sha256_prefix":"0f57192d632b4c3f","entry":"exp","repo":"jpmorganchase/cf-shap-facct22","repo_kind":"listed","path":"emutils/latex.py","file_url":"https://github.com/jpmorganchase/cf-shap-facct22/blob/HEAD/emutils/latex.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"0f57192d632b4c3f"}},{"code_sha256_prefix":"2bb7c5f5b3a4c17c","entry":"expand_dims_counterfactuals","repo":"jpmorganchase/cf-shap","repo_kind":"official","path":"src/cfshap/utils/_utils.py","file_url":"https://github.com/jpmorganchase/cf-shap/blob/HEAD/src/cfshap/utils/_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"2bb7c5f5b3a4c17c"}},{"code_sha256_prefix":"3a4957442e0cea29","entry":"function_cache","repo":"jpmorganchase/cf-shap","repo_kind":"official","path":"src/cfshap/utils/_python.py","file_url":"https://github.com/jpmorganchase/cf-shap/blob/HEAD/src/cfshap/utils/_python.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"3a4957442e0cea29"}},{"code_sha256_prefix":"35f417db85063189","entry":"is_xp_col","repo":"jpmorganchase/cf-shap-facct22","repo_kind":"listed","path":"explanations.py","file_url":"https://github.com/jpmorganchase/cf-shap-facct22/blob/HEAD/explanations.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"35f417db85063189"}},{"code_sha256_prefix":"411314cff681cc43","entry":"latex_config_decorator","repo":"jpmorganchase/cf-shap-facct22","repo_kind":"listed","path":"emutils/latex.py","file_url":"https://github.com/jpmorganchase/cf-shap-facct22/blob/HEAD/emutils/latex.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"411314cff681cc43"}},{"code_sha256_prefix":"9c9fe6d665155cf1","entry":"replace_nan","repo":"jpmorganchase/cf-shap-facct22","repo_kind":"listed","path":"utils.py","file_url":"https://github.com/jpmorganchase/cf-shap-facct22/blob/HEAD/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"9c9fe6d665155cf1"}},{"code_sha256_prefix":"bfffd44741ec05c4","entry":"safe_mean","repo":"jpmorganchase/cf-shap-facct22","repo_kind":"listed","path":"utils.py","file_url":"https://github.com/jpmorganchase/cf-shap-facct22/blob/HEAD/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"bfffd44741ec05c4"}},{"code_sha256_prefix":"665b007249dd5e26","entry":"safe_std","repo":"jpmorganchase/cf-shap-facct22","repo_kind":"listed","path":"utils.py","file_url":"https://github.com/jpmorganchase/cf-shap-facct22/blob/HEAD/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"665b007249dd5e26"}},{"code_sha256_prefix":"42ffb205b177a200","entry":"skl_binary_wrapper","repo":"jpmorganchase/cf-shap-facct22","repo_kind":"listed","path":"emutils/model/wrappers.py","file_url":"https://github.com/jpmorganchase/cf-shap-facct22/blob/HEAD/emutils/model/wrappers.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"42ffb205b177a200"}},{"code_sha256_prefix":"749ee3ced30b14d9","entry":"skl_predict_binary","repo":"jpmorganchase/cf-shap-facct22","repo_kind":"listed","path":"emutils/model/wrappers.py","file_url":"https://github.com/jpmorganchase/cf-shap-facct22/blob/HEAD/emutils/model/wrappers.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"749ee3ced30b14d9"}},{"code_sha256_prefix":"ac418a20a2bb48f6","entry":"xps_to_df","repo":"jpmorganchase/cf-shap-facct22","repo_kind":"listed","path":"explanations.py","file_url":"https://github.com/jpmorganchase/cf-shap-facct22/blob/HEAD/explanations.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"ac418a20a2bb48f6"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}