An example-based explanation is an explanation of a machine learning model that selects specific data instances to clarify how the model behaves, instead of summarizing the behavior with feature weights or rules. In Explainable AI, this family includes counterfactual examples, prototypes and criticisms, influential training instances and nearest-neighbor explanations, all of which answer the question “which concrete cases make this prediction understandable?”
The approach mirrors how people reason in medicine, law and engineering: experts often justify a judgment by comparison with known cases. Example-based methods are largely model-agnostic, although some, such as influence functions, require access to gradients, and some architectures, such as ProtoPNet, build examples into the model itself.
How example-based explanations work
Every example-based method combines three ingredients: a pool of candidate instances, a notion of similarity or influence, and a selection rule. The pool is usually the training set, but it can also be synthetic points generated by search. The similarity notion may be a distance in raw feature space, a distance in the model’s learned embedding space, or a measure of how much an instance changes the model’s parameters.
The selected instances are then presented next to the prediction being explained. A reader infers the reasoning by contrast: if the model labels a loan applicant as high risk and the closest training cases were all defaults, the decision appears consistent; if a small change would flip the decision, that change reveals the decisive factor.
Example-based explanations differ from feature attribution methods such as SHAP or LIME in the form of the answer, not necessarily in its scope. They can be local, explaining one prediction, or global, summarizing a model or dataset through a handful of representative cases.
Main types of example-based explanations
The field recognizes five principal types, each answering a different question about the model. The table summarizes them.
| Type | Question answered | Typical technique |
|---|---|---|
| Counterfactual example | What minimal change would alter the prediction | Optimization with proximity and sparsity terms |
| Prototype | Which instances represent a class or cluster | MMD-critic, k-medoids |
| Criticism | Which instances the prototypes fail to represent | MMD-critic witness function |
| Influential instance | Which training points most shaped this prediction | Influence functions, TracIn, deletion diagnostics |
| Nearest neighbor | Which known cases the model treats as similar | k-NN search in embedding space |
Counterfactual explanations are the most widely discussed type because they are actionable: they tell an affected person what would need to change. Prototypes and criticisms work together, since prototypes alone can hide minority subgroups that a model handles poorly. Influential instances connect explanations to training data attribution and are valuable for debugging mislabeled or poisoned data.
Comparison with feature-based explanations
Example-based and feature-based explanations are complementary rather than competing. Feature attribution states how much each input contributed; an example shows what a similar or contrasting case looks like. The table compares the two families.
| Aspect | Example-based explanation | Feature-based explanation |
|---|---|---|
| Output form | Concrete instances | Scores or weights per feature |
| Best data types | Images, text, tabular cases with meaning | Tabular data with interpretable features |
| Human intuition | High, matches case-based reasoning | Moderate, requires numeric literacy |
| Main dependency | Choice of similarity metric | Choice of baseline or background data |
| Privacy exposure | Can reveal real training records | Usually aggregate, lower exposure |
| Faithfulness risk | Similar cases may not reflect model logic | Attributions may be unstable |
Example-based methods are strongest when the data itself is intuitively interpretable, such as images, short texts or patient records. They are weakest for high-dimensional tabular data with hundreds of engineered features, where even a single instance is hard for a person to read.
Quality criteria and choosing a method
Good example-based explanations satisfy measurable quality criteria. For counterfactuals, the key criteria are validity (the prediction actually changes), proximity (the change is small), sparsity (few features change), plausibility (the result lies in a realistic region of the data) and actionability (only mutable features change). Age or ethnicity, for instance, must not be suggested as changes.
The right method depends on the audience and on the goal, as the decision table shows.
| Goal | Recommended method | Reason |
|---|---|---|
| Give recourse to a rejected applicant | Counterfactual examples | Shows achievable changes |
| Summarize a large dataset for auditors | Prototypes with criticisms | Covers typical and atypical cases |
| Find mislabeled training data | Influential instances | Exposes points that drive errors |
| Support a radiologist’s review | Nearest neighbors in embedding space | Matches clinical case comparison |
| Build an inherently interpretable vision model | Prototype layers such as ProtoPNet | Reasoning uses learned prototypes |
Limitations and common pitfalls
The most serious limitation is the dependence on a similarity metric. Two instances that look alike to a person may be far apart in the model’s representation, and the reverse also happens. An explanation built on raw-feature distance may therefore be unfaithful to the model, which ties this Term closely to explanation faithfulness.
- Rashomon effect for counterfactuals: many different counterfactuals can be valid, and presenting only one can mislead.
- Privacy leakage: showing real training records can expose personal data and enable membership inference.
- Computational cost: exact influence functions require inverse Hessian approximations that scale poorly to large networks.
- Cherry-picking risk: a developer can select flattering examples unless the selection rule is fixed and documented.
- Cognitive overload: more than a few examples per explanation usually reduces, rather than improves, understanding.
Practitioners therefore fix the selection procedure in advance, report how many valid alternatives exist and, in regulated settings, use synthetic or anonymized examples instead of raw records.
Put simply
An example-based explanation answers with cases, not numbers. A doctor might say a scan looks like three earlier scans that showed the same illness. A model can do the same thing. It points to past examples that it treats as similar.
It can also show what would need to change. For example, a slightly higher income would have led to loan approval. People find this easy to understand because it is how we explain things to each other every day.
In practice
A dermatology clinic uses an image classifier that flags skin lesions as suspicious or benign. Doctors were reluctant to trust a single probability score, so the development team added a nearest-neighbor panel: for each new image, the system shows the four most similar training images in the model’s embedding space, each with its confirmed biopsy result.
In one review, the model rated a lesion as suspicious with a score of 0.81. Three of the four neighbors were confirmed melanomas, but the panel also revealed that all three had a surgical ruler visible in the frame, as did the new image. The team audited the training set with influential-instance analysis and found that rulers correlated strongly with malignant labels.
After cropping rulers and retraining, the model’s reliance on that artifact disappeared. The example-based view therefore did more than build trust: it exposed a hidden shortcut that aggregate accuracy metrics had not revealed.