counterfactuals: An R Package for Counterfactual Explanation Methods

Susanne Dandl, Andreas Hofheinz, Martin Binder, Bernd Bischl, Giuseppe Casalicchio
4/13/2023
stat.MLcs.LGstat.CO

No official code found. Best implementation: JuliaTrustworthyAI/CounterfactualExplanations.jl (129 stars, MIT, last commit 2026-03-15). 1 more below.

Abstract

Counterfactual explanation methods provide information on how feature values of individual observations must be changed to obtain a desired prediction. Despite the increasing amount of proposed methods in research, only a few implementations exist whose interfaces and requirements vary widely. In this work, we introduce the counterfactuals R package, which provides a modular and unified R6-based interface for counterfactual explanation methods. We implemented three existing counterfactual explanation methods and propose some optional methodological extensions to generalize these methods to different scenarios and to make them more comparable. We explain the structure and workflow of the package using real use cases and show how to integrate additional counterfactual explanation methods into the package. In addition, we compared the implemented methods for a variety of models and datasets with regard to the quality of their counterfactual explanations and their runtime behavior.

View on arXivView PDF

Code Implementations(2)

LGPL-3.0

counterfactuals: An R package for Counterfactual Explanation Methods

295R, HTMLMar 19, 20219 months agoLGPL-3.0
interpretable-machine-learninglocal-explanationsmodel-agnostic-explanations
MIT

A package for Counterfactual Explanations and Algorithmic Recourse in Julia.

1296Julia, JavaScriptDec 22, 20217 months agoMIT
counterfactual-explanationsdeep-learningexplainable-aijuliamachine-learning

Similar Papers

Cite this paper

@article{dandl2023counterfactuals,
  title  = {counterfactuals: An R Package for Counterfactual Explanation Methods},
  author = {Susanne Dandl and Andreas Hofheinz and Martin Binder and Bernd Bischl and Giuseppe Casalicchio},
  year   = {2023},
  eprint = {2304.06569},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2304.06569v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2304.06569.svg)](https://codeofpaper.com/paper/2304.06569)

Discussion