← Back to Experiments

Counterfactual XAI

Design Pattern Library

An explainable AI (XAI) design pattern library for designing the moment after an AI system decides: what happened, what would need to change, and how much confidence a user should place in the result.

Self-initiated / 2025 66 interaction patterns Explainable AI
Type Experiment
Stack HTML · CSS · Babel JSX
Focus Explainability patterns
Status Live dashboard

What it is

Counterfactual XAI is a pattern dashboard for explainable AI interfaces. It maps explanation types across confidence, what-if simulation, comparison, actionability, attribution, provenance, transparency, and progressive disclosure.

The dashboard treats each explanation as an interface problem before it treats it as a technical one. Users need to understand what the model decided, what changed the outcome, what remains uncertain, and what action is actually available to them.

What-If Simulator › Counterfactual Explanation
38 / 66
What-If Simulator

Counterfactual Explanation

Shows the specific profile changes that would flip the outcome, ranked by feasibility and impact.

Current 38%
Counterfactual 60%
  • Portfolio None → Submitted
    Low effort +14
  • Assessment 74/100 → 82/100
    Med effort +8

Why I built this

I've spent enough time inside AI products to know the real UX problem is not the model alone. It is the moment after the model decides. Most products show a score, a label, or a percentage and call that transparency. It usually leaves the user with a verdict, not a way forward.

Counterfactual explanations change the frame from "here is what the model saw" to "here is what would have to be different for another outcome." That shift turns an opaque decision into something a person can inspect, challenge, and act on.

Component language

The dashboard is built from reusable explanation components rather than one-off screens. Each pattern has a scenario, a category tag, a demo frame, and a short interaction rule so the explanation stays concrete.

Confidence

Show uncertainty before precision

Confidence bars, meters, distributions, and warning states help users see when the AI output deserves review.

What-if

Make model logic explorable

Sliders, toggles, and scenario cards let users test changes directly instead of reading static explanations.

Comparison

Separate current from possible

Before/after cards and delta views make the gap between the current outcome and a better outcome visible.

Slider What-If Explorer
Years of experience 5 yrs
Assessment score 82/100
Projected outcome Likely to advance
76%

What I learned building it

The design problem and the engineering problem became the same problem: how much should the interface reveal before it becomes noise? The strongest patterns lead with the user's situation, then expose the model mechanics only when they help the next decision.

The constraint that helped most was giving each pattern one core interaction. No nested modals, no feature pile-up. One thing changes, one consequence becomes visible, and the user can decide whether to go deeper.

What's unresolved

Open exploration works for designers who already know what they are looking for. It is less helpful for someone arriving with an AI fairness ticket and no map. The next version should start with a guided question: what decision are you trying to explain?