Skip to main content
Interactive 3D/Counterfactual Explanations
Distance Metric
n_counterfactuals3
15
Immutable Features
HUD
Original Prob
0.139
DENIED
CF Prob (best)
-
APPROVED
Min Distance
-
Features Changed
-
"What is the smallest change that flips the prediction?" Red ✗ = denied. Green ✓ = approved counterfactual.

Counterfactual Explanations - Interactive Visualization

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.