Skip to main content

Visual Explanations of the Explainers, to Gain Insight into Predictions from High-Dimensional Models

Authors
Affiliations

Janith Wanniarachchi

Monash University

Dianne Cook

Monash University

Kate Saunders

Monash University

Patricia Menendez

University of Melbourne

Thiyanga Talagala

University of Sri Jayewardenepura

Abstract

Explainable Artificial Intelligence (XAI) methods such as SHAP, LIME, counterfactuals and Anchors are used on black box models to understand the contributions of features to individual predictions. These explanations are usually reported as numbers, in isolation from the data and the model that produced them. Visualising the explanations together with the observed data and the model’s predictions shows which facets of the model each method explains. This paper proposes a set of geometric representations for visualising these four XAI methods in the data space, illustrated on a two-dimensional classification example. The representations build intuition for how each method works, showing for example that the contribution indicated by SHAP is a different quantity from the local slope indicated by LIME, and help explain why different methods can return different explanations for the same prediction. Combined with a common scale for the explanations, they help practitioners judge which explanation to trust, rather than relying on the method whose answer best matches their prior beliefs.

1 Introduction

Explainable Artificial Intelligence (XAI) methods emerged in response to the increasing complexity and opaqueness of machine learning models and the need to understand how they work, particularly deep learning models. A central aim of XAI is to provide algorithmic and mathematical methods that gather insights into how black box models make decisions, addressing concerns related to trust, transparency, and accountability in AI systems (Ali et al. 2023). XAI methods are now used wherever black box predictions inform consequential decisions, including clinical care, where SHAP has been used to explain real-time predictions of hypoxaemia during surgery (Lundberg et al. 2018); credit risk management, where lenders must justify individual decisions (Bussmann et al. 2021); and weather and climate science, where explanations are checked against known physical processes (McGovern et al. 2019). In such high-stakes settings an explanation that misrepresents the model can do real harm (Rudin 2019).

Interpreting how predictors relate to a response is not new to statistics. In parametric models such as linear and generalized linear models, the fitted coefficients describe the effect of each predictor directly, and the statistical tradition has long emphasized interpretation alongside prediction (Breiman 2001b). As models become more flexible, coefficients lose this direct meaning, and statisticians have turned to quantities computed from the model’s predictions instead. Marginal effects, predictions and comparisons summarize how the predicted response changes as one predictor changes, and can be computed for any model, as implemented in the marginaleffects package (Arel-Bundock et al. 2024). Partial dependence plots (Friedman 2001) and accumulated local effects (Apley and Zhu 2020) apply the same idea to black box models by averaging predictions over the data (Molnar 2022). Variable importance measures, such as the permutation importance introduced for random forests (Breiman 2001a) and its extension to whole classes of models (Fisher et al. 2019), rank predictors by how much the model relies on them. These statistical tools and XAI methods share a common aim, describing a fitted model through its predictions, and differ mainly in whether they summarize the model over the whole dataset or at a single observation.

XAI methods are commonly distinguished by their scope and by the range of models they apply to (Molnar 2022). By scope, a method is either global or local (Molnar et al. 2020). Local methods describe the model’s decision process, or the influence of each feature, for a single observation of interest. Global methods describe the effect of the predictors across the entire dataset, often by aggregating local explanations. Partial dependence plots (Friedman 2001; Greenwell et al. 2017) and accumulated local effect plots (Apley and Zhu 2020) are common global methods, while SHAP (Lundberg and Lee 2017), Anchors (Ribeiro et al. 2018) and counterfactuals (Wachter et al. 2018) are common local methods.

By the range of models they apply to, methods are either model-specific, able to explain only one family of models such as tree-based models or neural networks, or model-agnostic, able to explain any black box model regardless of its architecture. Model specific methods use underlying information about the model’s architecture to provide explanations while the model agnostic methods use the model as a function of the input data to approximate the internal workings of the model. Most XAI methods are model agnostic with a few model specific methods available specifically to deep learning models such as saliency maps (Simonyan et al. 2013) and learned feature visualization (Olah et al. 2017) where information on the internal gradients are available.

Despite the advances in the current landscape of XAI methods, the explanations from these methods are inspected in isolation from the components that lead up to the explanation. Currently many of the XAI visualisation methods such as ModelStudio (Baniecki and Biecek 2019) focus primarily on showing feature contributions of the model based on different explanation methods (Baniecki et al. 2023). While these visualisations are effective in communicating the numerical values from explanations, these visualisations also suffer from being unable to communicate how the underlying explanations relate to the model’s view of the data and the data itself.

This isolation brings forward the issue of practitioners having to navigate a fragmented ecosystem of XAI techniques without a unified framework to guide them (Lundberg and Lee 2017). As different XAI methods probe different mathematical facets of a model, they inherently capture different aspects of the decision-making process. Consequently, when multiple methods are applied to the same pipeline, they frequently yield conflicting explanations. Resolving these disagreements currently forces practitioners to manually reconcile abstract algorithmic formulas with raw numerical outputs.

This paper introduces visualisations that explain the explainers, building intuition for how each explainer works, and for why different explainers can return different explanations for the same prediction. Each explanation is drawn as a geometric object in the data space, alongside the data, the model’s predictions and the perturbations the explainer used to produce it. Seeing these layers together shows what question each method answers, and makes it possible to trace a disagreement back to the step in the explanation process where the methods part ways.

The remainder of this paper is organized as follows. Section 2 outlines the prediction workflow and introduces the simulated dataset (Section 2.1) and the model (Section 2.2) used throughout the paper, then shows how the workflow is visualized in the data space (Section 2.3). Section 3 extends this workflow to local explanations, describing the perturbation, optimization and explanation stages shared by the explainers. Section 4 defines SHAP, LIME, counterfactuals and Anchors, and gives a geometric representation for each. Section 5 puts the explanations on a common scale, so that agreement and disagreement between the explainers can be assessed, and Section 6 discusses what the representations reveal, how they extend to higher dimensions, and their limitations.

2 Understanding the building blocks behind the prediction workflow

The general workflow for prediction is shown in Figure 1. It begins with a dataset of \(N\) observations \(\mathcal{D} = \{(\mathbf{x}_1, y_1), \dots, (\mathbf{x}_N, y_N)\}\), where each \(\mathbf{x}_i = (x_{i1}, \dots, x_{ip})\) is a vector of \(p\) feature values and \(y_i\) is the corresponding response. In this general setting the response may be categorical, giving a classification problem, or continuous, giving a regression problem, and the features may be numeric or categorical. The dataset is partitioned into a training dataset \(\mathcal{D}_{\text{train}}\) and a testing dataset \(\mathcal{D}_{\text{test}}\), with \(\mathcal{D}_{\text{train}} \cap \mathcal{D}_{\text{test}} = \emptyset\). A learning algorithm is applied to \(\mathcal{D}_{\text{train}}\) to produce a fitted model \(\hat{f}\), which maps a feature vector \(\mathbf{x}\) to a prediction \(\hat{y} = \hat{f}(\mathbf{x})\). The testing dataset is held out during training. The fitted model is applied to it to obtain predictions \(\hat{y}_k = \hat{f}(\mathbf{x}_k)\) for each \((\mathbf{x}_k, y_k) \in \mathcal{D}_{\text{test}}\), and comparing \(\hat{y}_k\) with the observed \(y_k\) measures how well the model generalizes to unseen data.

The XAI methods considered in this paper apply to both classification and regression. The geometric representations developed in later sections, however, are currently defined for classification, and this paper focuses on binary classification with numeric features.

flowchart LR
    A["Dataset 𝒟"] --> B["Training set 𝒟<sub>train</sub>"]
    A --> C["Testing set 𝒟<sub>test</sub>"]
    B --> D["Fitted model f̂"]
    C --> F["Predictions ŷ = f̂(x)"]
    D --> F
    F --> G["Evaluate: ŷ vs y"]
Figure 1: The workflow when the goal is to optimize for prediction. The dataset \(\mathcal{D}\) is split into disjoint training and testing sets; the model \(\hat{f}\) is fitted on the training set only and scored by comparing its predictions \(\hat{y}\) with the observed responses \(y\) in the testing set. Explanations, introduced in Section 3, are added on top of this pipeline rather than replacing it.

2.1 The dataset

To illustrate the problem, this paper uses a simulated two-dimensional binary classification dataset, \(\mathcal{D}\), where \(p = 2\) and \(y_i \in \{A, B\}\) for \(i = 1, \dots, N\), with \(A\) and \(B\) denoting the two class labels. The dataset contains \(N =\) 5000 observations of two numeric features, where each feature is drawn independently from a uniform distribution, \(x_{ij} \sim U(-1, 1)\) for \(j = 1, 2\). The class of each observation is assigned by the following rule, where the cases are checked from top to bottom and the first that applies sets the class.

\[ y_i = \begin{cases} B, & \text{if } x_{i2} < -1 + 0.8x_{i1} \\[6pt] A, & \text{if } x_{i1} < -0.5 \text{ AND } x_{i2} < -0.3 \\[6pt] A, & \text{if } -0.5 \le x_{i1} < 0.4 \text{ AND } x_{i2} < 0.1 + 0.8x_{i1} \\[6pt] A, & \text{if } x_{i1} \ge 0.4 \\[6pt] B, & \text{otherwise} \end{cases} \]

The dataset is split at random into a training set of 4000 observations and a testing set of 1000 observations.

Four observations of interest, shown in Figure 2, were chosen in the feature space to demonstrate how XAI methods explain individual predictions. Each lies within about 0.01 of the model’s prediction boundary, next to a different part of it, where local explanations are most difficult and where explainers are most likely to disagree. Point 1, at \((0.01, 0.10)\), lies on the upper sloped edge \(x_2 = 0.1 + 0.8x_1\). Point 2, at \((0.37, 0.40)\), lies at the corner where this sloped edge meets the vertical edge \(x_1 = 0.4\). Point 3, at \((0.39, 0.65)\), lies beside the vertical edge, where only \(x_1\) can change the class. Point 4, at \((0.65, -0.48)\), lies on the lower sloped edge \(x_2 = -1 + 0.8x_1\), where both features can change the class. The same four observations are used in every figure that follows.

Figure 2: The four observations of interest used throughout the paper. The top panel shows the observations in \(\mathcal{D}\) over the feature space, with colour giving the class predicted by the random forest (the faint background is the prediction surface on a dense grid). The numbered black diamonds mark the observations of interest, and the bottom panels zoom in on a \(\pm 0.1\) window around each one. Every observation sits next to a bend or corner of the predicted boundary, so a small change in either feature can change its predicted class.

2.2 The model

The methods in this paper do not depend on the type of model. All that is required is a fitted model \(\hat{f}\) that returns a prediction at any feature vector \(\mathbf{x}\), including values that were not in the training data. As an example, a random forest (Breiman 2001a) with 10 trees was fitted to the training set. A random forest is a well-known model whose training algorithm is simple to state, yet whose fitted function has no closed form that can be read directly, which makes it a typical black box. A small number of trees was used so that the fitted boundary keeps the axis-aligned steps of the individual trees (Figure 3), which creates local non-linearities around the observations of interest. The model classifies 100.0% of the testing set correctly, and agrees with the true class at 99% of the points on a dense grid over the feature space.

2.3 Visualizing the prediction workflow

For the current problem, expanding upon the workflow in Figure 1, there are three primary components, along with one optional baseline, that should be visually inspected together. The optional baseline is the true decision boundary; while rarely available in practice, it can be included in simulated scenarios as a ground truth reference. The three core components consist of the training dataset \(\mathcal{D}_{\text{train}}\), visualized to show the data distribution the model learned from; the testing dataset \(\mathcal{D}_{\text{test}}\), which demonstrates how the model performs on held out data; and the learned decision surface. This surface represents the model’s predictions generated over a dense, simulated grid encompassing all possible feature values, so that its behavior can be visualized across the entire feature space.

An example is provided in Figure 3 to illustrate how these elements are visually integrated.

Figure 3: Components of the prediction workflow for the two-dimensional example, drawn in the same feature space \((x_1, x_2)\) with colour giving the class: (a) the true class boundary on a dense grid, (b) the training data with observed classes, (c) the testing data with observed classes, and (d) the classes predicted by the random forest on the same grid as (a). Comparing (d) with (a) shows that the model recovers the overall shape of the boundary but replaces the sloped section with axis-aligned steps, which is where local explanations become difficult.

3 Generalizing the workflow for explanations

Previously, the workflow in Figure 1 focused on building a model for prediction. As the objective shifts toward explaining the inner mechanisms of that model, the purpose of an explanation must first be defined. At its core, an explanation should answer a fundamental question: which features were most influential in driving the model’s prediction for a specific observation?

This paper focuses on local, model-agnostic methods. Local explanations are valuable because AI systems increasingly support decisions that directly affect individual people, making observation-specific justification essential, and because model decision boundaries often become highly non-linear around difficult or edge-case observations (James et al. 2013), where a global summary says little about the behavior near a single point. Restricting attention to model-agnostic methods keeps the framework applicable regardless of the underlying predictive model, avoiding dependence on architectures that may become obsolete as new machine learning methods emerge.

Compared to the purely predictive pipeline, the explanatory workflow illustrated in Figure 4 introduces several vital components. Beyond the trained model and the input data, the process now incorporates a specific target observation and a customized explanation generated for it. Although existing XAI algorithms differ considerably in their exact implementations, they can all be understood through a unified framework consisting of three fundamental stages: a perturbation mechanism, an optimization objective, and a final explanation output.

The process begins with a perturbation mechanism, which generates a simulated collection of synthetic observations in the immediate neighborhood of the target instance. This collection, defined as the local perturbation dataset, maps out the feature space around the specific observation being analyzed. The method of generating these neighbors varies across algorithms, ranging from feature masking in SHAP and random local sampling in LIME, to a search over candidate points in counterfactuals and selective perturbation outside candidate rules in Anchors.

Next, the black-box model evaluates these simulated neighbors to produce local predictions. These outputs are fed into an optimization objective, which aligns the perturbed data and their predictions according to a method-specific criterion. In traditional statistics, parametric models inherently possess a functional form that explicitly outlines the contribution of each predictor. Machine learning models, however, are complex procedural algorithms lacking such transparency. To bridge this gap, the optimization stage frequently involves fitting a simple, interpretable surrogate model—referred to as the local parametric model. Whether it is a generalized linear model (GLM), a ridge regression, or a shallow decision tree, this surrogate mimics the black-box model’s behavior within the local neighborhood. While not every XAI method requires an explicit surrogate model (SHAP computes additive attributions directly, counterfactuals search for the nearest point of the other class, and Anchors optimize rules), all rely on applying an optimization criterion to local predictions.

Ultimately, the optimized representation is returned as the final explanation. Depending on the underlying XAI method, this output takes an interpretable form tailored to the user’s needs, such as feature importance coefficients, Shapley values, decision rules, or a modified counterfactual input. Together, these three stages provide a cohesive abstraction for seemingly disparate model-agnostic methods.

flowchart LR
    subgraph Prediction [Prediction workflow]
        A["Dataset 𝒟"] --> B["Training set 𝒟<sub>train</sub>"] --> C["Fitted model f̂"]
    end

    subgraph Explanation [Explanation workflow]
        X["Observation x<sub>i</sub>"] --> P["1. Perturbation<br/>𝒵 near x<sub>i</sub>"]
        P --> Q["Predictions f̂(𝒵)"]
        Q --> O["2. Optimization<br/>criterion over 𝒵, f̂(𝒵)"]
        O --> E["3. Explanation E<sub>i</sub>"]
    end

    C --> Q
Figure 4: The generalized workflow when optimizing for local model explanation. The Prediction workflow panel repeats Figure 1 and supplies the fitted model \(\hat{f}\). The Explanation workflow panel shows the three stages shared by local model-agnostic explainers: perturbations \(\mathcal{Z}\) are drawn around the observation \(\mathbf{x}_i\), scored by \(\hat{f}\), and passed to a method-specific optimization criterion that returns the explanation \(E_i\). The methods differ only in how each stage is filled in (SHAP: feature coalitions and Shapley values; LIME: a weighted sample and surrogate coefficients; counterfactuals: a search for the nearest opposite-class point; Anchors: rule perturbation and a high-precision box), which is what allows their outputs to be drawn in a common geometric space.

4 XAI methods and their geometric representation

From the many available local interpretability methods, this paper focuses on SHAP, LIME, counterfactuals and Anchors, as they are model agnostic and therefore can be applied to a wide variety of models (Molnar 2022). Each follows the three stages of Figure 4, but fills them in differently, and so each answers a different question about the model: how much each feature contributes to the prediction (SHAP), what the local boundary looks like (LIME), how far the observation is from the other class (counterfactuals), and which region around the observation keeps the same prediction (Anchors). This section defines each method and then proposes a geometric representation that draws its explanation in the data space.

The following notation is used throughout the paper. From here on the fitted black box model \(\hat{f}\) of Section 2 is written simply as \(f\), where \(f(\mathbf{x})\) is the model’s predicted probability that an observation with features \(\mathbf{x}\) is in class \(A\), and \(\hat{y}(\mathbf{x})\) is the class the model predicts. The observation to be explained is \(\mathbf{x}_i = (x_{i1}, \dots, x_{ip})\), with \(x_{ij}\) the value of feature \(j\).

The perturbation mechanism generates \(R\) new points \(\mathcal{Z} = \{ \mathbf{z}_1, \dots, \mathbf{z}_R \}\) around \(\mathbf{x}_i\). The points are drawn inside a box, the neighborhood of \(\mathbf{x}_i\), whose lower and upper corners are \(\mathbf{D}_{il} = (D_{i1l}, \dots, D_{ipl})\) and \(\mathbf{D}_{iu} = (D_{i1u}, \dots, D_{ipu})\).

Each XAI method \(m\) returns a \(p\)-dimensional explanation vector for observation \(i\), \[ \mathbf{E}_i^{(m)} = \lbrack E_{i1}^{(m)}, \dots, E_{ip}^{(m)} \rbrack, \qquad m \in \{S=\text{SHAP}, L=\text{LIME}, C=\text{Counterfactual}, A=\text{Anchors}\}, \] where \(E_{ij}^{(m)}\) is the value method \(m\) assigns to feature \(j\).

4.1 SHAP

SHAP (Lundberg and Lee 2017) attributes a prediction to the features using Shapley values from cooperative game theory. It measures how the expected prediction changes when the true value of a feature is revealed, compared with when that feature is left unknown.

SHAP splits the model’s prediction for observation \(\mathbf{x}_i\) into \(p\) pieces, one per feature, collected in the explanation vector \(\mathbf{E}_i^{(S)} = \lbrack E_{i1}^{(S)}, \dots, E_{ip}^{(S)} \rbrack\).

Each value \(E_{ij}^{(S)}\) is the amount by which feature \(j\) moves the prediction away from a baseline \(\bar{f_{\mathcal{Z}}}\). The baseline is the average prediction over a set of background points; in this paper these are the perturbed points, \(\bar{f_{\mathcal{Z}}} = \frac{1}{R}\sum_{r=1}^R f(\mathbf{z}_r)\). The key property of SHAP values is that they add up: the baseline plus all \(\mathbf{E}_i^{(S)}\) values gives back the model’s prediction for \(\mathbf{x}_i\),

\[ f(\mathbf{x}_i) = \bar{f_{\mathcal{Z}}} + \sum_{j=1}^{p} E_{ij}^{(S)}. \]

To decide how much of the gap between \(\bar{f_{\mathcal{Z}}}\) and \(f(\mathbf{x}_i)\) belongs to each feature, SHAP fixes the true values of \(\mathbf{x}_i\) one subset of features at a time and insert samples for the other features. Let \(\mathcal{P} = \{1, \dots, p\}\) be the set of all features and \(\mathcal{S} \subseteq \mathcal{P}\) a subset (a coalition) of revealed features. For the two-feature problem (\(p = 2\)), \(\mathcal{P} = \{1, 2\}\) has four subsets, so \(\mathcal{S}\) is one of \(\varnothing\), \(\{1\}\), \(\{2\}\) and \(\{1, 2\}\).

Define the value function \(v(\mathcal{S})\) as the average prediction when the features in \(\mathcal{S}\) are fixed at their values in \(\mathbf{x}_i\) and the remaining features are taken from the background points,

\[ v(\mathcal{S}) = \frac{1}{R}\sum_{r=1}^{R} f\big(\mathbf{x}_{i\mathcal{S}}, \mathbf{z}_{r\bar{\mathcal{S}}}\big), \]

where \((\mathbf{x}_{i\mathcal{S}}, \mathbf{z}_{r\bar{\mathcal{S}}})\) is the point whose \(j\)-th coordinate is \(x_{ij}\) if \(j \in \mathcal{S}\) and \(z_{rj}\) otherwise. Here \(\bar{\mathcal{S}}\) refers to the complement of the set.

Therefore the value function takes on the following form.

\[ \begin{aligned} v(\varnothing) &= \frac{1}{R}\sum_{r=1}^{R} f(z_{r1}, z_{r2}) = \bar{f_{\mathcal{Z}}} && \text{(no feature revealed)},\\ v(\{1\}) &= \frac{1}{R}\sum_{r=1}^{R} f(x_{i1}, z_{r2}) && \text{(only feature 1 revealed)},\\ v(\{2\}) &= \frac{1}{R}\sum_{r=1}^{R} f(z_{r1}, x_{i2}) && \text{(only feature 2 revealed)},\\ v(\{1,2\}) &= f(x_{i1}, x_{i2}) = f(\mathbf{x}_i) && \text{(all features revealed)}. \end{aligned} \]

For example, \(v(\{1\})\) is computed by taking every perturbed point \(\mathbf{z}_r\), overwriting its first coordinate with \(x_{i1}\) while keeping its own second coordinate \(z_{r2}\), and averaging the model’s predictions over these \(R\) modified points. The difference \(v(\{1\}) - v(\varnothing)\) is then how much the average prediction changes once feature 1 is revealed.

The change caused by setting feature \(j\) to the actual value depends on which other features are already revealed, so SHAP averages this change over every coalition \(\mathcal{S}\) that does not contain \(j\),

\[ E_{ij}^{(S)} = \sum_{\mathcal{S} \subseteq \mathcal{P} \setminus \{j\}} \frac{|\mathcal{S}|!\,(p - |\mathcal{S}| - 1)!}{p!} \Big[v(\mathcal{S} \cup \{j\}) - v(\mathcal{S})\Big]. \]

With \(p = 2\) the weights are both \(\frac{1}{2}\), so each SHAP value is the average of two differences,

\[ \begin{aligned} E_{i1}^{(S)} &= \frac{1}{2}\Big[v(\{1\}) - v(\varnothing)\Big] + \frac{1}{2}\Big[v(\{1,2\}) - v(\{2\})\Big],\\ E_{i2}^{(S)} &= \frac{1}{2}\Big[v(\{2\}) - v(\varnothing)\Big] + \frac{1}{2}\Big[v(\{1,2\}) - v(\{1\})\Big]. \end{aligned} \]

Adding the two lines gives \(E_{i1}^{(S)} + E_{i2}^{(S)} = v(\{1,2\}) - v(\varnothing) = f(\mathbf{x}_i) - \bar{f_{\mathcal{Z}}}\), which is exactly the additivity property above.

For general \(p\), the Shapley formula needs the value function for all \(2^p\) coalitions, which becomes expensive as \(p\) grows. KernelSHAP (Lundberg and Lee 2017; Mayer and Watson 2024) approximates the Shapley values from a sample of coalitions instead. Since \(p\) is small in this paper, every coalition is enumerated and the SHAP values are computed exactly.

Two features may not be enough to show fully how SHAP behaves. SHAP is designed for models with many features: in general, the value for feature \(j\) averages its marginal contribution over all \(2^{p-1}\) coalitions of the other features, and so summarizes how the feature acts alongside many different subsets of features. With \(p = 2\) the average has only the two terms shown above, and additivity then fixes \(E_{i2}^{(S)} = f(\mathbf{x}_i) - \bar{f_{\mathcal{Z}}} - E_{i1}^{(S)}\), so the two values are not free to vary independently and any interaction between the features is split equally between them. With more features, the value of a feature depends on how it interacts with many subsets of the others, which a two-feature example cannot show.

Intuitively, the SHAP value \(E_{ij}^{(S)}\) measures the contribution of feature \(j\) to the difference between the prediction \(f(\mathbf{x}_i)\) and the baseline \(\bar{f_{\mathcal{Z}}}\). A larger value in magnitude indicates a stronger influence. Values can be positive or negative, which means that the features push the prediction in opposite directions.

4.1.1 Geometric representation of SHAP

Each SHAP value is a contribution of one feature to the prediction, so it can be drawn as a force acting on the prediction, pulling it along one feature axis. The SHAP values are therefore visualized as axis-parallel arrows starting at \(\mathbf{x}_i\), one per feature, with length proportional to \(|E_{ij}^{(S)}|\) and pointing in the positive direction of the axis when the feature raises the predicted probability of class \(A\) and in the negative direction when it lowers it. The features are assumed to be on a common scale when visualizing. The arrows do not show where \(\mathbf{x}_i\) would have to move to change class. They show how far revealing each feature value moves the prediction away from the neighborhood average \(\bar{f_{\mathcal{Z}}}\), which is the quantity SHAP measures. Drawing them over the predicted classes lets the reader compare this credit with the shape of the boundary near \(\mathbf{x}_i\).

Figure 5: Geometric representation of SHAP in two dimensions. Each observation of interest (black diamond) carries two axis-parallel arrows, one per feature, whose length and direction give the SHAP value of that feature; the background shows the class predicted by the random forest. The bottom panels zoom in on each observation. Comparing the two arrows at a point shows at a glance which feature SHAP credits most, and whether the features push the prediction in the same or opposite directions.

4.2 LIME

LIME explains the prediction for \(\mathbf{x}_i\) by fitting a simple, interpretable surrogate model \(g\). As this paper focuses on a classification problem, \(g\) is a logistic regression model fitted to the perturbed points. The surrogate model is typically chosen from the family of models \(\mathcal{G}\) containing generalized or linear models such that it mimics the predictions of the black box model \(f\) within \(\mathcal{Z}\) (Ribeiro et al. 2016). The perturbed points \(\mathcal{Z}\) are given a weight \(\pi_{\mathbf{x}_i}(\mathbf{z}_r)\) that is large when \(\mathbf{z}_r\) is close to \(\mathbf{x}_i\) and small when it is far away.

The explanations from LIME are the result of an optimization problem that balances two criteria: a measure of goodness of fit and a measure of complexity. The measure for the goodness of the fit, \(\mathcal{L}(f, g, \pi_{\mathbf{x}_i})\) measures how badly \(g\) reproduces the predictions of \(f\) on the perturbed points, with each point counted according to its weight. Smaller values mean \(g\) is a more faithful copy of \(f\) near \(\mathbf{x}_i\). For the measure of complexity, \(\Omega(g)\) penalizes complicated surrogates, for example a linear model with many non-zero coefficients.

Put together, the surrogate model is then chosen by solving the following optimization problem,

\[ \arg\min_{g \in \mathcal{G}} \mathcal{L}(f, g, \pi_{\mathbf{x}_i}) + \Omega(g). \]

For the local model the predictors are \(\mathbf{z}_r, r = 1, \dots, R\) while the response is the black box model’s predicted probability \(f(\mathbf{z}_r)\). Thereby the link function for the local model \(g\) can be defined as

\[ \log\left(\frac{f(\mathbf{z}_r)}{1 - f(\mathbf{z}_r)}\right) = \beta_0 + \sum_{j=1}^{p} \beta_j z_{rj}, \qquad r = 1, \dots, R. \]

The coefficients are estimated by weighted maximum likelihood, using the weights \(\pi_{\mathbf{x}_i}(\mathbf{z}_r)\), together with a LASSO penalty \(\lambda \sum_{j} |\beta_j|\) that plays the role of \(\Omega(g)\) by shrinking unimportant coefficients towards zero. The LIME explanation is the vector of fitted slopes,

\[ \mathbf{E}_i^{(L)} = \lbrack \hat{\beta}_1, \dots, \hat{\beta}_p \rbrack, \]

so that \(E_{ij}^{(L)} = \hat{\beta}_j\). Because the features are scaled before fitting, the coefficients are on a comparable scale across features.

Intuitively, LIME provides the slopes \(E_{ij}^{(L)} = \hat{\beta}_j\) of a logistic regression that mimics the model near \(\mathbf{x}_i\). Larger values in magnitude indicate more influential features. Positive and negative values indicate that the features operate in opposite directions.

4.2.1 Geometric representation of LIME

A LIME explanation is only as good as the surrogate it comes from, and the surrogate is fitted to the perturbed points \(\mathcal{Z}\) and the black box predictions \(f(\mathcal{Z})\). The representation therefore draws both. The perturbed points are plotted around \(\mathbf{x}_i\), coloured by the class predicted by the surrogate \(g\), over the class predicted by the black box model \(f\) in a lighter shade. Because \(g\) is a logistic regression, the points it assigns to each class are separated by a straight line, \(\hat{\beta}_0 + \hat{\beta}_1 z_1 + \hat{\beta}_2 z_2 = 0\) in two dimensions, and the colour split among the perturbed points shows where this line lies.

Figure 6: Geometric representation of LIME in two dimensions. Around each observation of interest (black diamond) the perturbed points \(\mathcal{Z}\) are drawn and coloured by the class predicted by the local surrogate model, over the faint prediction surface of the random forest. The bottom panels zoom in on each neighbourhood. Where the colour split among the perturbed points matches the background, the surrogate is faithful to the model; where it does not, the LIME coefficients describe a boundary the model does not have.

The LIME explanation \(\mathbf{E}_i^{(L)} = \lbrack \hat{\beta}_1, \hat{\beta}_2 \rbrack\) is the normal vector of the surrogate’s boundary line. A boundary that is close to vertical has a large \(|\hat{\beta}_1|\), so \(x_1\) is the more important feature, and a boundary close to horizontal makes \(x_2\) the more important feature. Reading the importance from the figure therefore amounts to looking at the direction in which the colour of the perturbed points changes most quickly. Comparing the surrogate’s colours with the black box classes underneath shows whether this line is a faithful copy of the model near \(\mathbf{x}_i\). Where the black box boundary bends or has a corner inside the neighborhood, no single line can follow it, and the coefficients describe a boundary that the model does not have.

4.3 Counterfactuals

A counterfactual for observation \(\mathbf{x}_i\) is a point \(\mathbf{c}_i = (c_{i1}, \dots, c_{ip})\) that the model assigns to a different class, while being as close as possible to \(\mathbf{x}_i\). It answers the question: “what is the smallest change to the features that would flip the model’s prediction?” In other words, it shows where \(\mathbf{x}_i\) would need to move to cross the model’s decision boundary.

There are many methods of generating counterfactual explanations. This paper uses the What-If approach (Wexler et al. 2020), as implemented in the counterfactuals R package (Dandl et al. 2023), because its process is the most intuitive: rather than synthesizing a new point, it searches the observed data for the nearest observation that the model already classifies differently. Let \(y_i^{*}\) be the desired class, the class other than \(\hat{y}(\mathbf{x}_i)\), and let \(f_{y_i^{*}}(\mathbf{x})\) be the predicted probability that the model assigns to class \(y_i^{*}\). The set of candidate counterfactuals is the set of observations in the training set \(\mathcal{D}_{\text{train}}\) that the model places in the desired class,

\[ \mathcal{C}_i = \left\{ \mathbf{x}_k \in \mathcal{D}_{\text{train}} : f_{y_i^{*}}(\mathbf{x}_k) \geq 0.5 \right\}. \]

The counterfactual is the candidate closest to \(\mathbf{x}_i\),

\[ \mathbf{c}_i = \arg\min_{\mathbf{x}_k \in \mathcal{C}_i} d_G(\mathbf{x}_k, \mathbf{x}_i), \]

where closeness is measured by the Gower distance (Gower 1971)

\[ d_G(\mathbf{x}_k, \mathbf{x}_i) = \frac{1}{p} \sum_{j=1}^{p} \frac{|x_{kj} - x_{ij}|}{\Delta_j}, \]

and \(\Delta_j\) is the range of feature \(j\) in \(\mathcal{D}_{\text{train}}\). Dividing by \(\Delta_j\) puts every feature on a common scale, so that no single feature dominates the distance simply because it is measured in larger units.

Because the What-If approach only searches observed data, the counterfactual it returns depends on where the observations happen to lie. Other implementations search a grid or a simulated sample of points together with the model’s predictions at them, or optimize directly for a new point close to \(\mathbf{x}_i\) (Wachter et al. 2018; Dandl et al. 2020). These can return substantially different counterfactuals for the same observation, typically much closer to the model’s boundary, and so a different direction and a different explanation.

Because \(\mathbf{c}_i\) is drawn from \(\mathcal{D}_{\text{train}}\), it is guaranteed to be an observed data point. The trade-off is that it is the nearest observed point across the boundary rather than the nearest possible point, so the change it suggests may be larger than strictly necessary, particularly where the data are sparse near the decision boundary.

The counterfactuals in this paper are also free to change any feature, so \(\mathbf{c}_i\) is always the nearest observation of the opposite class. In practice only some features can be changed: a person can change their income but not their age, and some changes are only possible in one direction. Restricting the search to actionable features (Ustun et al. 2019) would change both the counterfactual and the importance derived from it, and the geometric representation would then need to show the features that were held fixed, for example as a constrained subspace through \(\mathbf{x}_i\).

The values returned for a counterfactual are the displacement from \(\mathbf{x}_i\) to its counterfactual \(\mathbf{c}_i\) along each feature, \(c_{ij} - x_{ij}\). A larger component in magnitude indicates more influence, because the shortest path to the opposite class moves mainly along that feature, so changing that feature is what flips the predicted class. The sign gives the direction in which the feature has to change.

4.3.1 Geometric representation of Counterfactuals

Figure 7: Geometric representation of counterfactuals in two dimensions. Each observation of interest (black diamond) is joined by a line segment to its counterfactual (crossed diamond), the nearest training observation that the model places in the other class; the background shows the class predicted by the random forest, and the hollow circles in the bottom panels are training observations. Closeness is measured by the Gower distance, which adds the scaled differences along each feature, so a point that looks closer in a straight line can be further away. The bottom panels zoom in on each segment. The direction of the segment shows which features must change to flip the prediction, and its length shows how far the observation is from the boundary.

A counterfactual explanation is itself a data point. Because the What-If approach selects the counterfactual from \(\mathcal{D}_{\text{train}}\), the point already exists among the plotted training observations, and it is highlighted rather than drawn as a new point. Joining \(\mathbf{x}_i\) to \(\mathbf{c}_i\) with a line segment draws the displacement \(\mathbf{c}_i - \mathbf{x}_i\) directly, so the explanation can be read from the segment: a segment that runs mostly along one axis shows that the change needed to flip the prediction is mostly in that feature. The model’s boundary must cross the segment somewhere between its ends, so the segment also gives a rough location of the boundary, whose exact position is usually unknown. Its length shows how far the nearest observed point of the other class is, which can be much further than the boundary itself where the training data are sparse.

4.4 Anchors

An anchor is a simple “if-then” rule that contains \(\mathbf{x}_i\) and that, when it holds, almost guarantees the model makes the same prediction as it does for \(\mathbf{x}_i\). The rule is built from conditions on individual features, such as \(x_{i1} > 0.2\). For numeric features, as in this paper, combining one such condition per feature gives a box around \(\mathbf{x}_i\),

\[ \mathcal{A}_i = \{\mathbf{z} : A_{ijl} \le z_j \le A_{iju} \text{ for } j = 1, \dots, p\}, \]

where \(A_{ijl}\) and \(A_{iju}\) are the lower and upper limits of the anchor for feature \(j\). A good anchor has two properties, both measured using perturbed points \(\mathbf{z}\) drawn from the neighborhood box \([\mathbf{D}_{il}, \mathbf{D}_{iu}]\) around \(\mathbf{x}_i\).

Precision is the probability that a point inside the anchor gets the same predicted class as \(\mathbf{x}_i\),

\[ \text{Prec}(\mathcal{A}_i) = P\big(\hat{y}(\mathbf{z}) = \hat{y}(\mathbf{x}_i) \mid \mathbf{z} \in \mathcal{A}_i\big). \]

It is estimated by the proportion of perturbed points inside the box that share the prediction of \(\mathbf{x}_i\). A high precision means the box is “pure”.

Coverage is the probability that a perturbed point falls inside the anchor,

\[ \text{Cov}(\mathcal{A}_i) = P(\mathbf{z} \in \mathcal{A}_i), \]

estimated by the proportion of perturbed points that lie inside the box. A high coverage means the rule applies to a large part of the neighborhood.

The two properties pull in opposite directions: a tiny box around \(\mathbf{x}_i\) is usually very pure but covers almost nothing. Anchors resolves this by finding the box with the largest coverage among those that are pure enough. Because precision is estimated from a sample, it is required to exceed a chosen threshold \(\tau\) (e.g. \(0.95\)) with high confidence, where \(\delta\) (e.g. \(0.05\)) is the accepted probability that this does not hold:

\[ \max_{\mathcal{A}_i} \ \text{Cov}(\mathcal{A}_i) \quad \text{subject to} \quad P\big(\text{Prec}(\mathcal{A}_i) \ge \tau\big) \ge 1 - \delta. \]

Intuitively, the anchor values compare the side lengths of the anchor box \(\mathcal{A}_i\) with those of the neighborhood box. A smaller relative side length indicates a more influential feature, because the box can only be extended a small amount in that direction, to get a more pure box.

4.4.1 Geometric representation of Anchors

Anchors are defined as a list of boundary conditions. These boundary conditions should be represented as a \(p\)-dimensional hyperrectangle in the data space. For two dimensions the boundary would be a rectangle while for high dimensions the generated boundary would be a \(p\)-dimensional hyperrectangle. However, simply drawing a box would not communicate the key information that Anchors provides: most of the points inside the box share the prediction for the observation. The representation therefore draws the anchor inside the neighborhood box from which the perturbations were drawn, with points coloured by their predicted class, so that the purity of the anchor (its precision) can be seen from the mix of colours inside it and its coverage from the share of the neighborhood it fills. The shape of the anchor carries the importance: a side that stays short shows a feature that had to be restricted to keep the box pure, while a side that stretches across the neighborhood shows a feature that could vary freely without changing the prediction.

Figure 8: Geometric representation of Anchors in two dimensions. For each observation of interest (black diamond) the anchor rule is drawn as a dark box, and the grey outlined box shows the region in which perturbations were drawn; points are coloured by class. The bottom panels zoom in on each anchor. A good anchor is a box whose contents are almost all of the observation’s predicted class, so the mix of colours inside the box shows how precise the rule is.

5 Extracting and standardizing information from explanations

The four methods return explanations in different forms. SHAP returns an additive attribution for each feature, LIME the coefficients of a local surrogate model, counterfactuals a new data point across the model’s boundary (or equivalently the change in each feature needed to reach it), and Anchors a box of feature ranges within which most points share the prediction for the observation. These explanations are therefore not directly comparable, as they measure different facets of the underlying model’s behavior. SHAP and LIME give attribution scores, while counterfactuals and Anchors rely on spatial quantities: the distance from the observation to its counterfactual, and the distances from the observation to the edges of the anchor box.

This section brings the explainers together in two ways so that they can be compared side by side. Visually, the geometric representations from Section 4 are drawn as glyphs in a single table, in the same data space as the model. Numerically, each explanation is converted into a \(p\)-dimensional vector and normalized to a common scale, so that the feature each method ranks first can be read off directly.

Recall from Section 4 that \(\mathbf{E}_i^{(m)}\) denotes the \(p\)-dimensional explanation vector for observation \(i\) using method \(m\), where \(m \in \{S=\text{SHAP}, L=\text{LIME}, C=\text{Counterfactual}, A=\text{Anchors}\}\).

SHAP and LIME (\(m \in \{S, L\}\))

For SHAP (\(m=S\)) and LIME (\(m=L\)), the explanation vectors are defined respectively as the SHAP values and the fitted logistic regression slopes (Section 4.1 and Section 4.2). For SHAP with more than two features, each value \(E_{ij}^{(S)}\) is a weighted average of the marginal contribution of feature \(j\) over every coalition of the other features, which is the same as averaging over every order in which the features could be added to the model (Shapley 1953; Štrumbelj and Kononenko 2014). The marginal contribution of a feature does depend on the order, because it depends on which features are already revealed, and attributions computed along a single order, such as break-down plots, can change when the order changes (Staniak and Biecek 2018). The SHAP value removes this dependence by averaging over all orders, so it does not depend on any single order, and the additivity property, \(\sum_{j} E_{ij}^{(S)} = f(\mathbf{x}_i) - \bar{f_{\mathcal{Z}}}\), holds for any \(p\):

\[ \mathbf{E}_i^{(S)} = \lbrack E_{i1}^{(S)}, \dots, E_{ip}^{(S)} \rbrack \]

\[ \mathbf{E}_i^{(L)} = \lbrack E_{i1}^{(L)}, \dots, E_{ip}^{(L)} \rbrack \]

Counterfactuals (\(m=C\))

Let \(\mathbf{x}_i\) be the observation of interest and \(\mathbf{c}_i\) be its corresponding counterfactual observation. The displacement vector between them is \(\mathbf{d}_i = \mathbf{c}_i - \mathbf{x}_i\).

The angle \(\theta_j\) between the displacement vector \(\mathbf{d}_i\) and the standard basis vector \(\mathbf{e}_j\) determines how directly the counterfactual moves along feature axis \(j\). The cosine of this angle is calculated using their dot product and magnitudes:

\[ \cos(\theta_j) = \frac{\mathbf{d}_i \cdot \mathbf{e}_j}{\Vert\mathbf{d}_i\Vert_2 \Vert\mathbf{e}_j\Vert_2} = \frac{c_{ij} - x_{ij}}{\Vert\mathbf{c}_i - \mathbf{x}_i\Vert_2} \]

The counterfactual explanation vector is thereby set as:

\[ \mathbf{E}_i^{(C)} = \left\lbrack \left|\frac{c_{i1} - x_{i1}}{\Vert\mathbf{c}_i - \mathbf{x}_i\Vert_2}\right|, \dots, \left|\frac{c_{ip} - x_{ip}}{\Vert\mathbf{c}_i - \mathbf{x}_i\Vert_2}\right| \right\rbrack \]

Anchors (\(m=A\))

Let \(\mathbf{D}_{iu}\) and \(\mathbf{D}_{il}\) be the upper and lower bounds of the perturbation distribution, and let \(\mathbf{A}_{iu} = (A_{i1u}, \dots, A_{ipu})\) and \(\mathbf{A}_{il} = (A_{i1l}, \dots, A_{ipl})\) be the corresponding upper and lower bounds of the anchor \(\mathcal{A}_i\). Each entry below is one minus the fraction of the neighborhood’s width that the anchor covers along feature \(j\), so a narrower anchor gives a larger value. The explanation vector is:

\[ \mathbf{E}_i^{(A)} = \left\lbrack 1 - \frac{A_{i1u} - A_{i1l}}{D_{i1u} - D_{i1l}}, \dots, 1 - \frac{A_{ipu} - A_{ipl}}{D_{ipu} - D_{ipl}} \right\rbrack \]

Normalizing feature importance

To put the explanations from all methods on a common scale, the absolute value of each entry is divided by the largest absolute entry for that observation and method. This gives normalized feature importance scores \(I_{ij}^{(m)} \in [0, 1]\), where the most important feature always scores 1, for any method \(m \in \{S,L,C,A\}\):

\[ I_{ij}^{(m)} = V(E_{ij}^{(m)}) = \frac{\vert{}E_{ij}^{(m)}\vert{}}{\max_{k = 1, \dots, p} \vert{}E_{ik}^{(m)}\vert{}} \]

Table 1: Explanations from SHAP, LIME, Anchors and counterfactuals at the four observations of interest. Each group of rows is one observation and each row within it one method. The Model column shows the training observations and the predicted class surface around \(\mathbf{x}_i\), the glyphs show each method’s geometric representation in the same space, the Raw explanation columns give each method’s output as usually reported, and the Normalized importance columns give \(I_{ij}^{(m)}\), where the most important feature scores 1. The explainers agree at Point 3, where only \(x_1\) can change the prediction, but disagree on which feature matters most elsewhere, most clearly at Points 2 and 4.
Point Model Method Explanation
Raw explanation E
Normalized importance I
x₁ x₂ x₁ x₂
1 SHAP 0.14 0.32 0.43 1.00
LIME −38.20 94.74 0.40 1.00
Counterfactuals 0.37 0.93 0.40 1.00
Anchors 0.20 0.40 0.50 1.00
2 SHAP −0.14 −0.06 1.00 0.47
LIME −69.30 56.99 1.00 0.82
Counterfactuals 0.58 −0.82 0.71 1.00
Anchors 0.45 0.40 1.00 0.89
3 SHAP −0.48 0.00 1.00 0.00
LIME −1001.34 0.00 1.00 0.00
Counterfactuals 0.98 0.20 1.00 0.21
Anchors 0.45 0.00 1.00 0.00
4 SHAP −0.16 −0.15 1.00 0.94
LIME 70.09 −86.70 0.81 1.00
Counterfactuals −0.99 0.13 1.00 0.13
Anchors 0.33 0.45 0.74 1.00

Table 1 collects the explanations for the four observations of interest. For each point, the Model column shows a close-up of the fitted model’s predicted class surface around \(\mathbf{x}_i\) (black diamond), with the nearby training observations overlaid. Each row within a point then gives one method’s glyph, drawn on the same close-up, in the order SHAP, LIME, counterfactuals and Anchors. The SHAP glyph draws an arrow from \(\mathbf{x}_i\) along each axis, with length equal to that feature’s Shapley value. The LIME glyph shows the perturbed samples coloured by the local surrogate’s prediction, so the split between colours is the surrogate’s linear boundary. The counterfactual glyph joins \(\mathbf{x}_i\) to its counterfactual \(\mathbf{c}_i\) (crossed diamond) in the opposite class. The Anchors glyph shows the anchor rule as a dark rectangle inside the grey perturbation box: the more tightly the anchor is bounded along a feature, the more that feature matters. The Raw explanation columns give \(E_{ij}^{(m)}\), which sit on very different scales across methods (LIME coefficients run into the hundreds, while counterfactual components lie in \([-1, 1]\)). The Normalized importance columns give \(I_{ij}^{(m)}\), where a value of 1 marks the feature the method ranks first.

The four points tell different stories. Point 3 sits beside a vertical stretch of the boundary, so only \(x_1\) can change the prediction. Every method agrees: SHAP, LIME and Anchors give \(x_2\) an importance of exactly 0, and the counterfactual moves almost entirely along \(x_1\). At Points 1 and 2 the counterfactual disagrees with the rest. At Point 1, SHAP, LIME and Anchors rank \(x_2\) first, while the counterfactual crosses the boundary mainly along \(x_1\). At Point 2, which lies at a corner of the boundary, SHAP and LIME rank \(x_1\) first and Anchors gives the two features equal importance, while the counterfactual moves mainly down in \(x_2\), because the nearest observation of the other class lies below and only slightly to the side of the point. Point 4 splits the methods into two pairs: LIME and Anchors favour \(x_2\), while SHAP and the counterfactual favour \(x_1\). SHAP does so only by a small margin (\(I =\) 0.94 for \(x_2\)). Near-ties such as this, and LIME’s 0.82 for \(x_2\) at Point 2, show that a method’s top feature can depend on a small difference in scores.

6 Discussion

An explanation is usually read on its own, as a bar chart of feature contributions or a table of numbers. This paper treats it instead as the last layer of a pipeline: the data, the model’s predictions on that data, the perturbations drawn around the observation, the optimization that turns the perturbations into an explanation, and finally the explanation itself (Figure 4). Table 1 is laid out to follow this pipeline from left to right. The Model column shows the first two layers, the training observations and the model’s predicted class surface around \(\mathbf{x}_i\). The glyphs add the perturbation and optimization layers, drawn in the same data space. The Raw explanation columns give the output of each method as it is usually reported. The Normalized importance columns put the outputs on a common scale so that they can be compared.

Reading the table in this order shows where two explainers part ways, not only that their final outputs disagree. The Model column already explains the agreement at Point 3, where the boundary near \(\mathbf{x}_i\) is vertical and only \(x_1\) can change the prediction, and the disagreement at Point 2, which sits at a corner of the boundary. The glyphs locate the disagreement in the layers that follow. The counterfactual answers a different question from the other methods: it follows the shortest path to the opposite class, so its direction depends on where the nearest observation of that class happens to lie. SHAP and LIME share the same neighborhood but optimize different criteria. SHAP credits the value \(x_{ij}\) relative to the neighborhood average, while LIME fits the slope of the local boundary, which is why they split at Point 4. The Raw explanation columns hide these reasons, because the methods report on scales that differ by orders of magnitude. The Normalized importance columns make the methods comparable, but they reduce each explanation to a ranking, and a ranking can turn on a near-tie.

The representations themselves are a deliberate choice. Most of the explainers could be drawn in the same way as LIME, by plotting the perturbations and the model’s predictions on them, since every method in Figure 4 starts from a perturbed neighborhood. Doing so would show the input of each method but not what it does with it. Each representation was instead chosen to draw the quantity the method optimizes: an arrow for an additive contribution in SHAP, a separating line for the slopes of the LIME surrogate, a segment for the displacement to a counterfactual, and a box for the region an anchor keeps pure. The comparison in Table 1 is possible only because these different outputs are first reduced to one format, a \(p\)-dimensional vector of normalized importances. Because that format does not depend on \(p\), the same comparison remains available in higher dimensions, even where the glyphs themselves become hard to draw.

None of the representations is tied to the plane. Each is a set of points, segments and flat pieces in \(\mathbb{R}^p\): \(p\) axis-parallel arrows for SHAP, perturbed points split by the surrogate’s \((p-1)\)-dimensional hyperplane for LIME, a segment for the counterfactual and a hyperrectangle for Anchors. A linear projection maps points to points, segments to segments and flat pieces to flat pieces, so the explanation can be appended to the data and projected with it. The layers of Table 1 can therefore be drawn in higher dimensions with a tour (Asimov 1985; Cook et al. 1995), which shows the data through a smooth sequence of two-dimensional projections (Wickham et al. 2011; Hart and Wang 2025).

Moving to higher dimensions has limitations. A single projection no longer shows everything. A SHAP arrow or a counterfactual segment looks short when its feature faces away from the viewer, a LIME hyperplane fills the view unless the projection contains its normal vector, and an anchor hyperrectangle hides its short sides in most views. Static figures therefore need a chosen view, for example a projection pursuit view of the local model boundary, or the plane spanned by the two features with the largest \(I_{ij}^{(m)}\). The cost also grows with \(p\): a perturbation grid grows exponentially in \(p\), and a hyperrectangle has \(p\,2^{p-1}\) edges. Tours remain practical up to 10 to 20 features (Lee et al. 2022). Beyond that the features must first be reduced, for example by principal components or by keeping the features that any explainer ranks highly.

A further limitation concerns the scope of the representations, which are defined for classification. SHAP, LIME and counterfactual methods apply equally to regression, but the class boundary that every glyph is drawn against has no direct counterpart for a continuous response, and extending the representations to regression, for example by drawing explanations against contours of the prediction surface, is left for future work.

These limits point to the need for interactivity, in two dimensions as well as in higher ones. Table 1 is a fixed set of small multiples for four points chosen in advance, and the choice of points is itself a decision that shapes what the reader sees. An interactive display would let the user select any observation and see its row of the table, switch each layer of the pipeline on and off, and change the size of the neighborhood and watch the explanations respond. In higher dimensions the user also needs to steer the projection, by moving between a grand tour, a guided tour towards the local boundary, a local tour around it and a slice through \(\mathbf{x}_i\) (Ursula Laa and Valencia 2020), with the table linked to the view. Such a display adds the last layer that Figure 4 leaves out, the person reading the explanation. It lets them explore each layer of the pipeline instead of relying on a fixed set of views, and bring their own knowledge of the data to decide which explanation to trust.

7 Conclusion

Local explanations from SHAP, LIME, counterfactuals and Anchors answer different questions about a model, and so they can disagree even for a two-feature model with a simple boundary. Drawing each explanation as a geometric object in the data space, alongside the data, the model’s predictions and the perturbations behind it, shows what each method measures and where in the explanation process two methods part ways. Putting the explanations on a common scale then allows them to be compared directly. The representations are defined in \(\mathbb{R}^p\) and can be extended to higher dimensions with tours, and an interactive display that lets the reader move between observations, layers and projections is the natural next step.

References

Ali, Sajid, Tamer Abuhmed, Shaker El-Sappagh, et al. 2023. “Explainable Artificial Intelligence (XAI): What We Know and What Is Left to Attain Trustworthy Artificial Intelligence.” Information Fusion 99: 101805. https://doi.org/https://doi.org/10.1016/j.inffus.2023.101805.
Apley, Daniel W, and Jingyu Zhu. 2020. “Visualizing the Effects of Predictor Variables in Black Box Supervised Learning Models.” Journal of the Royal Statistical Society Series B: Statistical Methodology 82 (4): 1059–86.
Arel-Bundock, Vincent, Noah Greifer, and Andrew Heiss. 2024. “How to Interpret Statistical Models Using marginaleffects for R and Python.” Journal of Statistical Software 111 (9): 1–32. https://doi.org/10.18637/jss.v111.i09.
Asimov, Daniel. 1985. “The Grand Tour: A Tool for Viewing Multidimensional Data.” SIAM Journal on Scientific and Statistical Computing 6 (1): 128–43. https://doi.org/10.1137/0906011.
Baniecki, Hubert, and Przemyslaw Biecek. 2019. “modelStudio: Interactive Studio with Explanations for ML Predictive Models.” Journal of Open Source Software 4 (43): 1798. https://doi.org/10.21105/joss.01798.
Baniecki, Hubert, Dariusz Parzych, and Przemyslaw Biecek. 2023. “The Grammar of Interactive Explanatory Model Analysis.” Data Mining and Knowledge Discovery, 1–37. https://doi.org/10.1007/s10618-023-00924-w.
Breiman, Leo. 2001a. “Random Forests.” Machine Learning 45 (1): 5–32. https://doi.org/10.1023/A:1010933404324.
Breiman, Leo. 2001b. “Statistical Modeling: The Two Cultures.” Statistical Science 16 (3): 199–231. https://doi.org/10.1214/ss/1009213726.
Bussmann, Niklas, Paolo Giudici, Dimitri Marinelli, and Jochen Papenbrock. 2021. “Explainable Machine Learning in Credit Risk Management.” Computational Economics 57 (1): 203–16. https://doi.org/10.1007/s10614-020-10042-0.
Cook, Dianne, Andreas Buja, Javier Cabrera, and Catherine Hurley. 1995. “Grand Tour and Projection Pursuit.” Journal of Computational and Graphical Statistics 4 (3): 155–72.
Dandl, Susanne, Andreas Hofheinz, Martin Binder, Bernd Bischl, and Giuseppe Casalicchio. 2023. Counterfactuals: An R Package for Counterfactual Explanation Methods. arXiv. https://doi.org/10.48550/arXiv.2304.06569.
Dandl, Susanne, Christoph Molnar, Martin Binder, and Bernd Bischl. 2020. “Multi-Objective Counterfactual Explanations.” Parallel Problem Solving from Nature – PPSN XVI, Lecture notes in computer science, vol. 12269: 448–69. https://doi.org/10.1007/978-3-030-58112-1_31.
Fisher, Aaron, Cynthia Rudin, and Francesca Dominici. 2019. “All Models Are Wrong, but Many Are Useful: Learning a Variable’s Importance by Studying an Entire Class of Prediction Models Simultaneously.” Journal of Machine Learning Research 20 (177): 1–81.
Friedman, Jerome H. 2001. “Greedy Function Approximation: A Gradient Boosting Machine.” Annals of Statistics, 1189–232.
Gower, J. C. 1971. “A General Coefficient of Similarity and Some of Its Properties.” Biometrics 27 (4): 857–71. https://doi.org/10.2307/2528823.
Greenwell, Brandon M et al. 2017. “Pdp: An r Package for Constructing Partial Dependence Plots.” R J. 9 (1): 421.
Hart, Casper, and Earo Wang. 2025. Detourr: Portable and Performant Tour Animations. https://casperhart.github.io/detourr/.
James, Gareth, Daniela Witten, Trevor Hastie, Robert Tibshirani, et al. 2013. An Introduction to Statistical Learning. Vol. 112. Springer.
Lee, Stuart, Dianne Cook, Natalia da Silva, et al. 2022. “The State-of-the-Art on Tours for Dynamic Visualization of High-Dimensional Data.” WIREs Computational Statistics 14 (4): e1573. https://doi.org/10.1002/wics.1573.
Lundberg, Scott M, and Su-In Lee. 2017. “A Unified Approach to Interpreting Model Predictions.” Advances in Neural Information Processing Systems 30.
Lundberg, Scott M., Bala Nair, Monica S. Vavilala, et al. 2018. “Explainable Machine-Learning Predictions for the Prevention of Hypoxaemia During Surgery.” Nature Biomedical Engineering 2 (10): 749–60. https://doi.org/10.1038/s41551-018-0304-0.
Mayer, Michael, and David Watson. 2024. Kernelshap: Kernel SHAP. https://github.com/ModelOriented/kernelshap.
McGovern, Amy, Ryan Lagerquist, David John Gagne, et al. 2019. “Making the Black Box More Transparent: Understanding the Physical Implications of Machine Learning.” Bulletin of the American Meteorological Society 100 (11): 2175–99. https://doi.org/10.1175/BAMS-D-18-0195.1.
Molnar, Christoph. 2022. Interpretable Machine Learning: A Guide for Making Black Box Models Explainable. Second edition. Christoph Molnar.
Molnar, Christoph, Giuseppe Casalicchio, and Bernd Bischl. 2020. Interpretable Machine Learning – A Brief History, State-of-the-Art and Challenges. Vol. 1323. http://arxiv.org/abs/2010.09337.
Olah, Chris, Alexander Mordvintsev, and Ludwig Schubert. 2017. “Feature Visualization.” Distill 2 (11): e7.
Ribeiro, Marco Tulio, Sameer Singh, and Carlos Guestrin. 2016. "Why Should I Trust You?": Explaining the Predictions of Any Classifier. https://doi.org/10.48550/ARXIV.1602.04938.
Ribeiro, Marco Tulio, Sameer Singh, and Carlos Guestrin. 2018. “Anchors: High-Precision Model-Agnostic Explanations.” Proceedings of the AAAI Conference on Artificial Intelligence 32 (1). https://doi.org/10.1609/aaai.v32i1.11491.
Rudin, Cynthia. 2019. “Stop Explaining Black Box Machine Learning Models for High Stakes Decisions and Use Interpretable Models Instead.” Nature Machine Intelligence 1 (5): 206–15. https://doi.org/10.1038/s42256-019-0048-x.
Shapley, Lloyd S. 1953. “A Value for n-Person Games.” In Contributions to the Theory of Games II, edited by Harold W. Kuhn and Albert W. Tucker, vol. 28. Annals of Mathematics Studies. Princeton University Press.
Simonyan, Karen, Andrea Vedaldi, and Andrew Zisserman. 2013. “Deep Inside Convolutional Networks: Visualising Image Classification Models and Saliency Maps.” arXiv Preprint arXiv:1312.6034.
Staniak, Mateusz, and Przemysław Biecek. 2018. “Explanations of Model Predictions with Live and breakDown Packages.” The R Journal 10 (2): 395–409. https://doi.org/10.32614/RJ-2018-072.
Štrumbelj, Erik, and Igor Kononenko. 2014. “Explaining Prediction Models and Individual Predictions with Feature Contributions.” Knowledge and Information Systems 41 (3): 647–65. https://doi.org/10.1007/s10115-013-0679-x.
Ursula Laa, Dianne Cook, and German Valencia. 2020. “A Slice Tour for Finding Hollowness in High-Dimensional Data.” Journal of Computational and Graphical Statistics 29 (3): 681–87. https://doi.org/10.1080/10618600.2020.1777140.
Ustun, Berk, Alexander Spangher, and Yang Liu. 2019. “Actionable Recourse in Linear Classification.” Proceedings of the Conference on Fairness, Accountability, and Transparency, 10–19. https://doi.org/10.1145/3287560.3287566.
Wachter, Sandra, Brent Mittelstadt, and Chris Russell. 2018. Counterfactual Explanations Without Opening the Black Box: Automated Decisions and the GDPR. arXiv. http://arxiv.org/abs/1711.00399.
Wexler, James, Mahima Pushkarna, Tolga Bolukbasi, Martin Wattenberg, Fernanda Viégas, and Jimbo Wilson. 2020. “The What-If Tool: Interactive Probing of Machine Learning Models.” IEEE Transactions on Visualization and Computer Graphics 26 (1): 56–65. https://doi.org/10.1109/TVCG.2019.2934619.
Wickham, Hadley, Dianne Cook, Heike Hofmann, and Andreas Buja. 2011. “Tourr: An R Package for Exploring Multivariate Data with Projections.” Journal of Statistical Software 40 (2): 1–18. https://doi.org/10.18637/jss.v040.i02.