Counterfactual explanation

A counterfactual explanation tells a person the smallest change to their circumstances that would have led an AI system to a different decision, such as the income that would have got a loan approved.

A counterfactual explanation answers a what-if question. Instead of describing how a model works inside, it describes the nearest alternative situation in which the model would have decided differently. A rejected loan applicant might be told that the application would have been approved with a higher annual income, or with fewer credit cards and no past default. The explanation is about this one decision, not the model as a whole.

The idea was set out for AI by Sandra Wachter, Brent Mittelstadt and Chris Russell in Counterfactual Explanations without Opening the Black Box: Automated Decisions and the GDPR, first posted in November 2017 and published in the Harvard Journal of Law and Technology in 2018. They argued that explaining a complex model's internals faces legal and technical barriers, but that a person affected by a decision mainly needs three things: to understand why it was reached, to have grounds to contest it, and to know what to change to get a better result next time. A counterfactual can serve all three without revealing the model's inner workings.

Finding a counterfactual is an optimisation problem. The method searches for an input that is as close as possible to the original but produces the desired output. Wachter and her co-authors balanced those two goals in a single formula. Later methods add more requirements: change as few features as possible, keep the result realistic, and offer several different options, as the DiCE method published in 2020 does. Many of them need only access to the model's predictions, not its code or training data.

There are pitfalls. A decision can have many valid counterfactuals that point in different directions, so whoever chooses which one to show shapes the message. Some changes are not actionable: telling an apartment owner that a larger flat would fetch more rent is true but useless, and telling someone to be younger is worse. Counterfactuals also describe the model, not the world, so they do not prove that changing a feature would cause a real-world outcome. Used carefully, they are one of the more practical ways to give people meaningful reasons for automated decisions.

Common questions

What is an example of a counterfactual explanation?

A bank's model rejects a loan, and the explanation says it would have been approved if the applicant's annual income had been higher by a stated amount. It tells the person what would have made the difference without describing how the model works.

How is a counterfactual explanation different from feature importance?

Feature importance tells you which inputs mattered most to a model's output. A counterfactual tells you what specific change to the inputs would have produced a different output, which is often more useful to the person affected.

Does the GDPR require counterfactual explanations?

No law requires counterfactuals as such. Wachter, Mittelstadt and Russell proposed them as a way for organisations to give meaningful explanations of automated decisions in the spirit of the GDPR without having to open up the model.

What are the limitations of counterfactual explanations?

There are usually many possible counterfactuals for one decision, and they can contradict each other. Some suggest changes people cannot make, and they explain the model's behaviour rather than proving cause and effect in the real world.

Finding more

Search for "counterfactual explanations Wachter", "DiCE counterfactual" and "actionable recourse machine learning". The original paper on arXiv and textbooks on interpretable machine learning explain the methods and their trade-offs, and open-source libraries document how they generate counterfactuals in practice. Be cautious with vendor claims that a single counterfactual fully explains a decision.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.