Context explanations

Understand how comparisons and scenarios enrich local explanations.
View as Markdown

Context explanations enrich local explanations by adding comparison or scenario context.

A local explanation describes why a model produced a prediction for a specific query. A context explanation compares that query, prediction, or attribution pattern with another condition or another case. This can make the explanation easier to interpret, especially when the question is not only “why this prediction?” but “how would this prediction change if something were different?”

Examples include what-if analysis, control swaps, and nearest-neighbour comparisons.

Why context explanations matter

Context explanations are comparative and contrastive.

They help explain a prediction by showing how it relates to alternatives:

ComparisonWhat it helps explain
A query compared with a modified version of itselfWhat changes when one input value changes.
A query compared with similar casesWhy the prediction is consistent with nearby examples.
A query compared with dissimilar casesWhat makes the query different from distant examples.
A query compared with related casesWhat additional context helps explain the prediction.

Control swap

A control swap explains how the value of a categorical feature affects a prediction.

It does this by comparing the original query with one or more versions of the same query where the categorical feature has been changed to another category.

For example, if a query involves a male person, the same query could be re-run with Gender set to Female to check whether the prediction changes. The prediction results can then be compared to see whether the outcome changed.

The module attributions and feature attributions can also be compared to identify where the differences appear and how the swap affected the prediction.

Because attributions are additive, they can be compared side by side or subtracted to calculate deltas. For example, to see the attribution effect of moving from Male to Female, subtract the original Male attributions from the Female attributions.

Control swap example

The example below shows a Gender control swap from Male to Female in a Hybrid Intelligence classification model.

In this case, the classification result did not change. The decrease in attributions shows bias favouring the Male class, but the final outcome was not affected.

Comparing the module and feature attributions shows that the largest attribution changes came from interactions between:

InteractionMeaning
Gender × Education_NumGender interacting with number of years in education.
Gender × EducationGender interacting with education level.

Control Swap: Classification and Total Attributions results

Control Swap: Classification and Total Attributions results.

Control Swap: Module attribution plots for original query, swap query and differences between the two (only attributions that changed shown)

Control Swap: Module attribution plots for original query, swap query and differences between the two (only attributions that changed shown)

Control Swap: Feature attribution plots for original query, swap query and differences between the two (only attributions that changed shown)

Control Swap: Feature attribution plots for original query, swap query and differences between the two (only attributions that changed shown)

Control Swap: Feature attribution tables for original query, swap query and differences between the two (only attributions that changed shown)

Control Swap: Feature attribution tables for original query, swap query and differences between the two (only attributions that changed shown)

Nearest neighbour

Nearest-neighbour explanations use similarity to provide context for a prediction.

By examining similar, dissimilar, and related queries, they can provide insight into the model’s decision-making process.

Similarity is enabled by vector embeddings. In Hybrid Intelligence, vector embeddings organise information by placing objects on a virtual map: similar objects are close together, and different objects are farther apart. This makes it easier to find patterns and relationships.

Similarity

Similar neighbours are close to the query according to a chosen distance metric.

They can help explain a prediction by showing that the query is similar to other cases with the same or similar outcomes.

Dissimilarity

Dissimilar neighbours are far from the query according to a chosen distance metric.

Contrasting the query with dissimilar neighbours can highlight what makes the query unusual or why it was predicted differently from distant cases.

Relatedness

Related neighbours may not be the closest by distance, but they share characteristics or patterns that are relevant to the explanation.

They can provide context or additional insight that may not be obvious from nearest neighbours alone.