Source-linked AI summary

Good Counterfactuals and Where to Find Them: A Case-Based Technique for Generating Counterfactuals for Explainable AI (XAI)

Mark T. Keane, Barry Smyth

arXiv:2005.13997v1cs.AI

TL;DR

Counterfactual explanations can be difficult to make sparse and plausible, and case-bases may contain few good examples. This paper retrieves and adapts known counterfactual patterns, reporting average explanatory competence just over 40%, up from an approximately 11% baseline.

  • Problem

    Most current XAI counterfactual techniques use perturbation and search and can struggle with sparsity and plausibility; whether case-bases contain good counterfactuals also remains to be established.

    Source: §2.3 · p. 5, §2.2 · p. 5
  • Method

    The paper retrieves and adapts patterns of good counterfactuals in a case-base to generate analogous counterfactuals for new queries.

    Source: §5.2 · p. 11, §6 · p. 13
  • Results

    Average explanatory competence rises from about 11% baseline to just over 40% after explanation-case retrieval and reuse, with adaptation further increasing it.

    Source: §5.2 · p. 11
  • Takeaways & Limitations

    The approach can improve counterfactual potential and explanatory coverage in case-bases that initially have few good counterfactuals.

    Source: §5.2 · p. 11, §6 · p. 13

    For multiclass datasets, evaluating an adaptation that considers all ordered nearest neighbours with a different class from the query is left for future work.

    Source: §5 · p. 10

Abstract

from arXiv · show

Recently, a groundswell of research has identified the use of counterfactual explanations as a potentially significant solution to the Explainable AI (XAI) problem. It is argued that (a) technically, these counterfactual cases can be generated by permuting problem-features until a class change is found, (b) psychologically, they are much more causally informative than factual explanations, (c) legally, they are GDPR-compliant. However, there are issues around the finding of good counterfactuals using current techniques (e.g. sparsity and plausibility). We show that many commonly-used datasets appear to have few good counterfactuals for explanation purposes. So, we propose a new case based approach for generating counterfactuals using novel ideas about the counterfactual potential and explanatory coverage of a case-base. The new technique reuses patterns of good counterfactuals, present in a case-base, to generate analogous counterfactuals that can explain new problems and their solutions. Several experiments show how this technique can improve the counterfactual potential and explanatory coverage of case-bases that were previously found wanting.

1 Introduction

The paper examines whether CBR can provide understandable counterfactual explanations for opaque machine-learning predictions, finding that good counterfactuals are rare in many case-bases and motivating a new case-based generation technique.

1 Introduction

  • CBR explanations use precedent-like cases, while counterfactual cases are nearest unlike neighbors that show how a prediction could change.The paper considers counterfactual explanations in a twin-system setting, where a CBR system explains predictions from an opaque machine-learning model.Source: §1 · pp. 1–2
  • Across 20 frequently used CBR case-bases, the authors find that good, comprehensible counterfactuals are quite rare.They call the topology of good counterfactuals in a case-base its counterfactual potential.Source: §1 · p. 2
  • This scarcity motivates explanatory coverage and a new case-based technique for generating counterfactual explanations by analogy.The paper develops and evaluates the technique to improve counterfactual potential and explanatory coverage.Source: §1 · p. 2

2 Counterfactual Explanation: Promise, Problems & Prospects

Counterfactual explanations contrast a prediction with an alternative outcome after feature changes, and are argued to offer causal, actionable explanations. Their promise is limited by prolixity, sparsity, and plausibility problems, motivating the paper’s case-based approach.

2.1 Counterfactual Promise

  • Counterfactuals contrast a prediction with an alternative outcome after feature changes, and proponents argue they support causal, actionable explanations and human-in-the-loop decisions.The paper presents nearest-unlike-neighbor explanations as more informative than nearest-like-neighbor explanations; the counterfactual format holds other features constant while changing specified variables.Source: §2 · pp. 2–3, §2.1 · p. 3
  • Counterfactuals are argued to aid causal explanation and cognition, outperform other explanation styles in one study, provide robust post-hoc explanations, and comply with GDPR [45].The paper also notes that Pearl’s structural Bayesian approach has been used to test AI fairness but less often for explanation generation.Source: §2.1 · p. 3

2.2 Counterfactual Problems

  • Random perturbation can produce many counterfactuals; minimizing feature changes addresses prolixity, while sparse explanations are defined here as changing one or two features despite limited evidence that sparsity improves explanations.The paper motivates its sparsity definition with evidence that people prefer single-feature changes when learning unfamiliar categories, unless domain knowledge indicates feature dependencies.Source: §2.2 · p. 4
  • Plausibility is least solved: generated counterfactuals may be invalid or impractical, whereas examples drawn from training data or a case-base have inherent plausibility.Proposed alternatives such as locking features or allowing user-set feature weights do not provide an automated solution; the paper asks how many good counterfactuals case-bases naturally contain.Source: §2.2 · pp. 3–5

2.3 CBR’s Prospects for Counterfactuals

  • The proposed case-based direction evaluates case-base potential by counting nearest unlike neighbors differing in no more than two features, then develops explanatory coverage and a generation technique tested on five datasets.The paper first measures counterfactual potential across 20 classic UCI datasets.Source: §2.3 · p. 5

3 Experiment 1: Plotting Counterfactual Potential

Experiment 1 assessed how often case-bases contain sparse counterfactuals across 20 commonly used UCI datasets. In nearly every dataset, good counterfactuals were rare, even when matching tolerance was introduced.

3 Experiment 1: Plotting Counterfactual Potential

  • The proportion of pairwise case-base comparisons with ≤2 feature differences provides an upper/lower bound on counterfactual potential; fine-tuning retrieval cannot help much when good counterfactual cases are absent.The analysis computes the number of feature differences across all pairwise case-base comparisons.Source: §3 · pp. 5–6

3.2 Results & Discussion

  • In nearly every dataset, 1-diff and 2-diff counterfactuals together account for <1% of cases, while most involve >5 feature-differences; matching tolerance typically leaves good counterfactuals rare.The analysis used exact feature matching, which is conservative for real-valued features; allowing values within 1% to match improves availability, but the fraction with ≤2 feature differences typically remains very low.Source: Table 2 · p. 6, §3.2 · pp. 6–7

3.1 Method: Data Sets & Procedure

  • The experiment compared 20 UCI datasets commonly used in CBR, pairing test cases and training cases on opposite sides of a decision boundary and counting their feature differences.All pairings of cases in the case-base were used to estimate the proportion of good counterfactuals, defined as having ≤2 feature differences.Source: §3 · pp. 5–6, §3.1 · p. 6

4 A Case-Based Technique for Good Counterfactuals

The technique reuses patterns from known good counterfactuals to generate plausible explanations for new cases, using a case base to guide feature changes and an ML model to verify class changes. It defines explanatory competence to measure how well a case base can explain its cases and builds on explanation-case pairs to generate new counterfactuals.

4 A Case-Based Technique for Good Counterfactuals

  • The technique addresses the scarcity of good counterfactuals by reusing patterns from known cases, rather than generating them blindly through perturbation.Across 50+ sampled BAC case-bases, good counterfactuals remained absent; the method uses existing counterfactuals as hints about which features to change and plausible values to use.Source: §4 · p. 7

4.1 Explanatory Competence

  • Explanatory competence measures the fraction of a case-base covered by cases that can explain another case’s solution.Its basic relation is explains(c, c'), where c is a counterfactual explaining the solution of c'; the coverage set contains cases with at least one such explanatory case.Source: §4.1 · p. 8

4.2 Leveraging Counterfactual Cases for Explanation

  • With similarity tolerances of 0.02 for Abalone and 0.025 for Liver, just over 20% and 4% of cases, respectively, have associated good counterfactuals.The method pairs cases with their good counterfactuals as explanation cases (XCs); pairs are symmetric, and each pair of unlike neighbours differing by no more than two features contributes two XCs.Source: §4.2 · p. 8

4.3 A Case-Based Approach to Generating Good Counterfactuals

  • For a target without an existing good counterfactual, the method retrieves the explanation case with the most similar query and combines target match-feature values with counterfactual difference-feature values.The resulting candidate changes no more than two features; an ML model checks whether its class differs from the target before it is accepted.Source: §4.2 · p. 9, §4.3 · p. 9
  • If the candidate retains the target’s class, adaptation substitutes difference-feature values from ordered nearest neighbours of the target with the counterfactual’s class until a class change occurs or adaptation fails.The method leaves match-features unchanged to avoid increasing the number of differences from the target.Source: §4.3 · p. 10
  • Explanation cases identify feature combinations to change or hold constant, and reusing values from real cases is intended to produce more plausible counterfactuals than arbitrary perturbations.The adaptation step may also find a suitable counterfactual closer to the query than retrieval alone.Source: §4.3 · p. 10

5 Experiment 2: Evaluating Explanation Competence

Experiment 2 evaluates whether case-based counterfactual generation improves explanations beyond the good counterfactuals naturally present in five ML/CBR datasets.

5 Experiment 2: Evaluating Explanation Competence

  • The reported adaptation considers nearest neighbours sharing the query’s class with the target; iterating over neighbours of other classes is left for future work.The proposed multi-class variation could expand the pool of difference-feature values and increase the likelihood of finding a good counterfactual.Source: §5 · p. 10

5.1 Method: Data & Procedure

  • The evaluation used 10-fold cross-validation, randomly reserving 10% of cases as queries and building the explanation case-base from the remainder.Explanatory competence was the fraction of queries associated with good counterfactuals; counterfactual distance measured their distance from the query. Baselines used a 1-2% matching tolerance and average distance to existing good counterfactuals.Source: §5.1 · p. 11

5.2 Results & Discussion: Explanatory Competence

  • Across five datasets, baseline competence averaged about 11%, retrieval/reuse raised it to just over 40%, and adaptation raised it to just under 94%.Figure 2 reports explanatory competence as the fraction of queries that can be explained.Source: Figure 2 · p. 11, §5.2 · p. 11

5.3 Results & Discussion: Counterfactual Distance

  • Retrieval/reuse counterfactuals averaged RCF » 1.2 (Liver RCF » 1.55), while adaptation averaged RCF » 1.1 and beat baseline in 3 out of 5 datasets.Choosing the closer counterfactual when both steps produced one yielded RCF <1 for all datasets; Figure 3 presents the relative distances.Source: Figure 3 · p. 12, §5.3 · pp. 12–13

6 Conclusions & Future Directions

The paper proposes a case-based approach that adapts known counterfactual associations to improve counterfactual potential, addressing sparsity, plausibility, and invalid-point risks in synthetic methods. Its utility depends on explanation cases and an underlying model for validation, while further user testing is needed.

Conclusions & Future Directions

  • The case-based technique adapts known counterfactual associations between query-problems and cases, improving the counterfactual potential of many datasets.The paper also clarifies good counterfactuals, introduces explanation competence, and reports evidence for the technique’s utility.Source: §6 · p. 13
  • Synthetic counterfactual methods often ignore domain training data, so they may lack sparsity and plausibility and can generate invalid points.The paper argues these methods do not guarantee good counterfactuals.Source: §6 · p. 13
  • The approach assumes some explanation cases and an underlying ML model for counterfactual validation, though the authors say such cases are typically feasible.A minimally viable case-base may be available even when good counterfactuals are rare, particularly if feature matching allows some tolerance.Source: §6 · p. 13
  • Further user testing is needed to assess the operational definition of good counterfactuals, despite support from prior psychological work.The authors conclude that case-based reasoning has much to offer counterfactual XAI.Source: §6 · p. 13
Loading 2005.13997v1…