Counterfactual explanations answer the question: 'What is the minimum change to the input that would flip the model's prediction?' Unlike SHAP or LIME which explain why a decision was made, counterfactuals explain what needs to change - actionable information for the person affected by the decision. Finding counterfactuals requires solving a constrained optimization problem near the decision boundary.
Place a data point, get the model prediction, and find the closest point on the decision boundary that yields the opposite class
See the minimal feature vector change needed - only the features that need to change are highlighted
Understand algorithmic recourse: if a loan is denied, counterfactuals show exactly what the applicant needs to change to get approved
Compare multiple counterfactuals for the same point - there are often many equally minimal flips
Learn the trade-off: counterfactuals should be sparse (few changes) and realistic (within the data distribution) - these two goals conflict
Part of the EngineersOfAI Interactive 3D - free interactive visualizations covering every major concept in machine learning and AI engineering. Hover any element for a plain-English explanation. No code required.