Explaining machine learning classifiers through diverse counterfactual explanations

Ramaravind Kommiya Mothilal, Amit Sharma, Chenhao Tan

TL;DR

This paper introduces a framework to generate Diverse Counterfactual Explanations (DiCE) for machine learning classifiers. Instead of just telling a user why a model made a decision, DiCE provides multiple, distinct, and feasible alternative scenarios showing how to change the outcome (e.g., how to get a rejected loan approved).

What Problem Does This Paper Address?

Most post-hoc explanation methods, like LIME or SHAP, rely on feature importance. They tell you which variables most heavily influenced a model's prediction. While useful for model developers, this doesn't help an end-user who wants to change their outcome. If a bank's algorithm rejects your loan application because of "poor credit history," that explanation doesn't give you a clear path forward.

Counterfactual explanations (CFs) solve this by offering "what-if" scenarios: "If your income was $10,000 higher, your loan would be approved." However, existing CF methods typically generate only a single explanation. If that single suggestion is impossible for the user to achieve (like changing their race or drastically lowering their age), the explanation is useless. This paper addresses the challenge of generating a set of counterfactual explanations that are both close to the original input (proximal) and distinct from one another (diverse), giving users actionable choices.

Methods

The authors formulate counterfactual generation as an optimization problem over a combined loss function. To generate $k$ counterfactual examples for an input $x$, the objective function balances three main properties:

  1. Validity (yloss): A hinge-loss function ensures that the generated examples actually flip the model's prediction to the desired class.
  2. Proximity: An $\ell_1$-distance metric (normalized by the Median Absolute Deviation of features) keeps the counterfactuals as close to the original user profile as possible.
  3. Diversity: This is the core novelty. The authors use Determinantal Point Processes (DPP) to maximize the diversity of the counterfactual set. DPP penalizes similarity between pairs of counterfactuals, forcing the algorithm to find distinct paths to the flipped prediction.

Additionally, the framework includes user-defined box constraints (e.g., "income cannot exceed $200,000") and a post-hoc sparsity enhancement step that greedily reverts feature changes if they don't impact the flipped prediction, ensuring users don't have to change too many things at once.

Datasets

The framework was evaluated on four real-world datasets commonly used in fairness and interpretability research:

  • Adult-Income: Predicting whether an individual's income exceeds $50,000.
  • LendingClub: Deciding loan approvals based on applicant history.
  • German-Credit: Assessing bank credit risk.
  • COMPAS: Predicting criminal recidivism risk.

Key Insights and Ideas

  • Truthfulness over Approximation: Unlike surrogate methods (like LIME) that approximate a model's local decision boundary and can "lie," counterfactuals are inherently truthful because they are direct evaluations of the actual model.
  • The 1-NN Proxy Experiment: To test human interpretability, the authors trained a simple 1-Nearest Neighbor (1-NN) classifier on just a handful of generated counterfactuals. They found this tiny proxy model could mimic the complex underlying model's local decision boundary remarkably well—often better than LIME, which requires thousands of samples.
  • Causal Feasibility: Independent feature perturbation can lead to absurd recommendations, such as gaining a higher educational degree without aging. The authors demonstrate that incorporating causal graphs to filter out impossible transitions is vital for real-world actionability.

Key Results

The proposed method, DiverseCF, was compared against several baselines across both linear and non-linear models.

Comparisons of DiverseCF with baseline methods on non-linear ML models

As shown in Figure 1:

  • Validity: DiverseCF consistently achieved nearly 100% valid unique counterfactuals across all datasets, even as the requested number of counterfactuals ($k$) increased up to 10. Baselines quickly degraded or produced duplicate entries.
  • Diversity: Continuous and categorical diversity scores were substantially higher for DiverseCF compared to proximity-only methods. For the LendingClub dataset, continuous diversity was up to 11 times higher than the baselines at $k=10$.
  • Boundary Approximation: In local decision boundary approximation tests, the 1-NN classifier trained on DiverseCF examples achieved a significantly higher F1 score for the counterfactual class than LIME on the Adult-Income and COMPAS datasets.

Limitations and Future Work

  • Gradient Access: The current optimization framework requires access to the gradients of the machine learning model, meaning it cannot natively support completely black-box models (though model-agnostic genetic algorithms could be explored).
  • Post-Hoc Causality: Causal constraints are currently handled via a post-hoc filtering step. The authors note it would be much more efficient to bake causal relationships directly into the optimization loop.
  • User Psychology: While generating diverse options is technically superior, the authors highlight the need for future behavioral studies to evaluate the cognitive load of "choice overload" on actual human users.

Summary updated

BibTeX
@inproceedings{mothilal2020explaining,
  author = {Ramaravind Kommiya Mothilal and Amit Sharma and Chenhao Tan},
  title = {{Explaining machine learning classifiers through diverse counterfactual explanations}},
  booktitle = {FAT},
  year = {2020},
  doi = {10.1145/3351095.3372850},
}
Figure