Defining Locality for Surrogates in Post-hoc Interpretablity

Defining Locality for Surrogates in Post-hoc Interpretablity


Local surrogate models, to approximate the local decision boundary of a black-box classifier, constitute one approach to generate explanations for the rationale behind an individual prediction made by the back-box. This paper highlights the importance of defining the right locality, the neighborhood on which a local surrogate is trained, in order to approximate accurately the local black-box decision boundary. Unfortunately, as shown in this paper, this issue is not only a parameter or sampling distribution challenge and has a major impact on the relevance and quality of the approximation of the local black-box decision boundary and thus on the meaning and accuracy of the generated explanation. To overcome the identified problems, quantified with an adapted measure and procedure, we propose to generate surrogate-based explanations for individual predictions based on a sampling centered on particular place of the decision boundary, relevant for the prediction to be explained, rather than on the prediction itself as it is classically done. We evaluate the novel approach compared to state-of-the-art methods and a straightforward improvement thereof on four UCI datasets.


1 Introduction

The task of explaining individual predictions made by a black-box classifier aims at providing to a human-user the rationale, or at least intuitions, about the factors leading to this prediction and, eventually, showing how the prediction can be altered by changing some of these factors Doshi-Velez et al. (2017). While it is clear in the current literature that there are still no consensual definitions of “explanations” and “interpretability” for machine learning algorithms and their predictions, we can nevertheless state that there is a consensus to say that providing an explanation for an individual prediction relies on finding the features that actually impact the prediction.

To do so, several types of approaches have been proposed. In this paper we consider post-hoc approaches, which are model-agnostic and classically applied to trained machine learning prediction models. For instance, sensitivity analysis Simonyan et al. (2013); Adler et al. (2018); Koh & Liang (2017) generates perturbations on the feature values of the instance of the prediction to explain in order to observe the consequences on the output of the black-box to outline the local behaviour of the black-box regarding its local decision boundary. Surrogate models Craven & Shavlik (1996); Hara & Hayashi (2016), on the other hand, train an interpretable model (e.g. linear regression or decision tree with low complexity) to mimic the black-box decisions in order to extract explanations from it. A particular case are the local surrogates Ribeiro et al. (2016) which, in order to better locally approximate the black-box decision boundary, propose to train an interpretable model locally in the neighborhood of the instance whose prediction by the black-box is to explain.

In this paper, we refine the notion of locality, the neighborhood on which a local surrogate is trained and show that it is not trivial to define the right neighborhood. We illustrate this issue using LIME Ribeiro et al. (2016): we show that choosing an adequate sampling strategy for generating the instances used to fit the surrogate model has a major impact on the quality of the approximation of the local black-box decision boundary and thus on the accuracy of the generated explanation. In particular, the effect of locally important features can be hidden by globally important ones. We show that this issue is not related to a simple parametrization to control the range of the sampled neighborhood: for instance, centering the sampling on the instance of the prediction to explain may not be the best location to approximate the black-box decision boundary. To solve this issue, we propose a novel approach to sample the right neighborhood to fit local surrogate models. The intuition is the following: since a local surrogate aims at approximating the local black-box decision boundary that matters for the prediction to explain, this boundary should be sought first in order to sample instances in its neighborhood to fit the local surrogate. This approach is experimented on both synthetic datasets and datasets from the UCI repository with significant improvement in the local fidelity of the surrogate.

The next section details the steps to generate interpretable local surrogates, with a focus on LIME that will be used in Section 3 to illustrate and analyze the locality issue of the sampling to fit local surrogates. Finally, in Section 4 a novel approach is proposed to sample the right neighborhood to fit local surrogate models. The data and code used in this paper are available online1.

2 Interpretable Local Surrogates

In this section we present the classical principles to generate interpretable local surrogates to extract explanations for individual predictions. Then we instantiate it with a current state-of-the-art and widely used in the industry approach, LIME Ribeiro et al. (2016). It is then also used in Section 3 to illustrate the locality issue in the sampling step to approximate a black-box decision boundary with local surrogates.

2.1 Principles

We consider a black-box classifier whose predictions are not understandable by a human expert. Given an instance associated with the prediction , the task at hand is to provide human-interpretable explanations for the rationale behind to approximate the local decision boundary of with a surrogate model from which explanations are extracted.

This process can be divided into three steps: (1) sample the feature space to generate a training set. Once the training set is obtained, (2) a surrogate can be fit using it in order to approximate the local decision boundary of . Constraints can be introduced in the loss function of the surrogate to control the complexity of the generated explanations or to impact the locality of the surrogate (see Section 2.2). Finally, (3) explanations are extracted from the surrogate . The form of the explanations depends on the surrogate type and on the chosen interpretability approach. In this paper, we will not discuss the question of the human-interpretability of the extracted explanations. We rely on admitted interpretability of the surrogate models as presented in the literature Guidotti et al. (2018). These three steps rely on assumptions and heuristics. In the next sections we propose to discuss the ones made in the step that will be the focus of this work, the sampling.

Regarding the sampling step, to fit the local surrogate  to approximate the local black-box decision boundary, an adequate training set composed by a set of instances  associated with their labels  is required. Since our objective is to approximate  in a post-hoc set-up, the labels associated to  are obtained from the the black-box classifier: . A crucial question is how to generate the set of instances . The instances in the training set , already used to train , could be used to fit the surrogate . However, may not be accessible, in particular when considering model-agnostic explainer systems. Also, it has been shown in Craven & Shavlik (1996) that locally increasing the density of instances is beneficial for the surrogate accuracy. For these reasons, it has been proposed to draw a new set of instances from the feature space . To do so, a strategy for the sampling of the instances  must be defined, in particular the parameters of the distribution from which the instances are drawn (law, center and range of the distribution) to define the neighborhood in which the training set of the surrogate  should focus. Different choices for these parameters directly impact the explanations, as the locality of the sampled instances  leads to different approximations of the local black-box decision boundary by the surrogate .

Sections 3 and 4 of this paper are respectively dedicated to a discussion on the impact of different strategies of sampling on the local fidelity of the surrogate  and a novel proposition to sample  in order to improve the local fidelity of the surrogate .

2.2 Lime

LIME generates an explanation for an individual prediction  by fitting a linear approximation of the local black-box decision boundary. LIME implements the process described above (Section 2.1) as follows. Regarding the sampling step (1), a set of instances  is drawn following a normal distribution with the same mean and standard deviation as the original feature space , independently from the instance  of the prediction  to explain. For the labels , LIME works with the prediction probabilities returned by . Regarding the surrogate fitting step (2), the surrogate of LIME is trained to approximate locally the black-box decision boundary with a linear regression with regularization (ridge). To fit a local surrogate centered on , each instance of  is associated to a weight calculated as its distance to  using a kernel function (RBF kernel by default): instances closer to  are assigned a higher importance during the training. Regarding the explanation generation step (3), human-interpretable explanations for the prediction  are generated by extracting the linear regression coefficients of the trained surrogate .

3 A Discussion about Locality Issues

As discussed in the previous section, locality can be enforced either in the sampling step or when fitting the surrogate. Ensuring that the surrogate is trained with the right locality is a major challenge to avoid the generation of inaccurate explanations. This section is devoted to the concept of locality and aims at highlighting the importance of incorporating it adequately for all surrogate model approaches.

3.1 Local vs. Global Features

Generating a local explanation for an individual prediction relies on finding the features that have a local influence over this prediction. In a supervised learning problem, we propose to make a distinction between two types of feature influences. Some features are expected to have a global influence when they impact predictions for instances over all the dataset and others to have a local influence when they impact predictions for small areas of the whole feature space. For instance, in a trained decision tree, features used close to the root have a more global influence than the ones used only in nodes that are close to the leaves.

Black-box decision boundaries often have local nuances and non-linearities, where global explanations based on global feature influences are not accurate. A local surrogate model trained to generate explanations for an individual prediction should have the ability to catch these local nuances: the features that matter locally to approximate the local black-box boundaries and relevant to explain the individual prediction. For instance, as explained earlier, LIME samples instances from the whole input space and weights them depending on their distance to the instance whose prediction we want to interpret. Our claim is that such an approach tends to hide the features with a local influence for the benefit of features with a global influence.

3.2 Locality in the Sampling Step

To fit a local surrogate, the sampling step must handle the sampling of the right instances, what we call the sampling locality, to feed and train a local surrogate. We use the decision boundary of the surrogates produced by LIME as an illustrative example. It is easy to visualize the provided linear approximation of the decision boundary: LIME recreates a local classification decision boundary along the hyperplane defined by , for . We apply LIME to a 2-dimensional half-moons dataset (1000 instances, see Figure 1), randomly split into a train set and a test set. A black-box classifier , a Random Forest with the default scikit-learn parameters in the present case, is trained on the train set resulting in a 0.93 AUC score on the test set. In what follows, we use LIME as provided by the library developed by its authors Ribeiro et al. (2016) with default parameters (if not mentioned otherwise). The library has been slightly modified to return the material needed to plot the LIME decision boundary.

Figure 1: Local linear approximations (dashed colored lines) provided by LIME for 3 predictions (big color points) on half-moons dataset. The black-box decision boundaries are represented by the blue and red areas.

Figure 1 illustrates the dataset and the decision border of as background (red vs. blue areas). In addition, for the 3 instances whose prediction is to explain (blue, green and red points, respectively , and ), the boundaries learned by LIME are plotted as the blue, green and red dotted lines. We observe that the decision boundaries learned by LIME do not match the direction of the local decision boundary of the black-box classifier, where far more vertical borders could be expected. For  (green dot) for instance, looking at the shape of the closest decision boundary of , a negative slope could have been expected for the decision boundary learned by LIME rather than a positive one. Another observation is that the slopes of the decision boundaries learned by LIME for these instances scattered across the dataset are similar, even though their respective local black-box decision boundaries are apparently different. These results tend to show that LIME’s decision boundaries sometimes approximate the global shape of the black-box decision boundary instead of its local one, resulting in local feature influences being mitigated in favour of global feature influence.

3.3 Evaluation: a Numerical Criterion for Locality

To get a quantitative evaluation of these observations, we propose a metric to assess the locality issue, and define the Local Fidelity as the fidelity of to within a neighborhood around :


where is a measure of accuracy, such as the AUC score, calculated over instances generated uniformly in . The surrogate is not affected by , since is defined after and purely used for evaluation. We propose to define the neighborhood of as a -hypersphere of radius centered on . This intuitive definition of locality allows us to make the radius of the fidelity hypersphere a proxy for the degree of locality considered. Since the radius value is heavily linked to the dimension and density of the input space , will be expressed in the rest of the paper as a percentage of the maximum distance between the instances of the dataset and , whose prediction is being interpreted.

Figure 2 shows the value of this criterion for LIME for the dataset and the 3 instances shown on Figure 1, for different values of . At a local scale, for low values of radius , the fidelity is significantly worse than at global scale, for higher values of . This confirms the previous observation: the approximation learned by the local surrogate is influenced by global features, which reduces the Local Fidelity at local scale of the local surrogate and thus the fidelity of the explanations it will generate for the individual prediction to explain.

Figure 2: Local Fidelity for 3 predictions provided by LIME on half-moons dataset for increasing values of .

In order to get insights about the quality of the local approximations of a surrogate model over a whole dataset, the definition of Local Fidelity can be extended to a set of instances by averaging over  in neighborhoods . Figure 3 shows a heatmap where each point of the test set is colorized depending of the Local Fidelity of LIME for . We can observe that LIME has trouble approximating areas where the local decision boundary of the black-box classifier  differs from the decision boundary approximating the whole dataset (ie. features with a local influence vs. features with a global influence). Our hypothesis for the rationale behind this behaviour is that for a local surrogate to fit properly a local decision boundary of the black box, the local data sampled and used to fit the surrogate should be in the neighborhood of the decision boundary to approximate. Instead, LIME weights instances sampled over the whole dataset with a kernel function of the distance to the to explain, which does not seem to be sufficient.

Figure 3: Visualization of the half-moons dataset and the Local Fidelity ( of LIME for each instance of the dataset.

4 A New Local Surrogate Training Workflow

In order to overcome the issues highlighted in the previous section, a first idea consists in modifying the kernel width of LIME, resulting in a new surrogate model that we call LIME-K. Here, we propose a more fundamental modification of the sampling stage in the local surrogate training workflow, LS, as described in the following.

4.1 Proposition : Local Surrogate (LS)

The main idea of our proposition relies on the assumption that in order to approximate a local decision boundary, the data used for the training of the surrogate model should be sampled precisely around the decision boundary itself. Although the criteria to maximize, , is calculated in an area centered around the instance , the final objective of remains to approximate the classification decision boundary of . Hence, sampling instances belonging to the two classes (which would not be guaranteed when sampling around ) is important.

Given an individual prediction to explain and a black-box classifier , our proposition for the sampling stage is as follows. First, the closest decision boundary of  is detected by looking for the closest instance such that . This is done by using the Generation part of the algorithm introduced in Laugel et al. (2018). The overall principle is to generate instances in a hypersphere of growing radius centered on  until it crosses the decision boundary of . Once  is found, training instances are sampled uniformly in a hypersphere  of radius  centered on  so that the shape of this closest decision border can be efficiently learnt: . The outline of the method is detailed in Algorithm 1.

Using adequate hyperparameters for (such as the number of instances generated at each step) guarantees to detect one of the closest points of the decision border of . Thus, performs an approximation of the local decision boundary of . The radius used to define the training subset of defines how local this approximation is.

  Input: , , ,
   Draw uniformly instances in an hypersphere of radius centered around
  Train on ()
Algorithm 1 Outline of LocalSurrogate algorithm

4.2 Experimental Results

The experimentation is conducted on the previous artificial half-moons dataset and on 4 UCI datasets.


The proposed algorithm is evaluated in comparison with LIME using the criterion presented in Section 3. As shown in Ribeiro et al. (2016) and discussed in Section 2.2, LIME ensures some level of locality by using a kernel to weight the sampled instances depending on their distance to the instance  whose prediction we want to to interpret. The width of this kernel could be set by the user to constraint locality in a more or less aggressive fashion. In this context, the proposed Local Surrogate approach is compared to LIME with default parameters (kernel width equals ) and to LIME with a reduced kernel width (that is optimized for each dataset based on performance) that we call LIME-K.

Half-moons dataset

Figure 4: Example of the linear approximations performed by LIME (with default kernel width), LIME-K (with reduced kernel width) and the proposed Local Surrogate for a randomly picked instance from the half-moons dataset (green dot ). The red dot corresponds to the closest instance from the other class  found with the algorithm.
Figure 5: Local Fidelity for an instance of the half-moons dataset for several values of .

We analyze the efficiency of the proposed approach at bringing locality in the same setup as before (Random Forest trained on half-moons) to facilitate the visualization of locality effects being learned by the local surrogate model. Figure 4 shows the decision boundaries of LIME (default kernel width ), LIME with a reduced kernel width parameter () and ther proposition () for a randomly picked instance of the dataset. As shown previously, the decision boundary learned by LIME (in green) is very horizontal, as an approximation of the global model would be. Even though reducing the kernel width helps in making the learned decision boundary more local (blue line), it is not enough to properly approximate the local border of the black-box classifier . In comparison, seems to be approximating a much more local border direction (red line), as its slope is much more vertical, as expected for this instance (green dot), giving us a more satisfying explanation.

These results can be further observed when looking at the scores of these learned decision boundaries for a given instance in Figure 5. The proposed Local Surrogate approach achieves higher Local Fidelity than LIME, even with reduced kernel width. This can be generalized to the whole test set, as shown by the differences in average Local Fidelity () in Table 1. This tends to confirm our initial assumption that even if weighting helps to integrate locality, the global sampling performed by LIME tends to mitigate the local feature effects in favor of the global ones.

UCI datasets

We apply the same experimental protocol to 4 classification datasets from the UCI repository (Breast Cancer, Default of Credit Card Clients, Online News Popularity and Tennis Major Tournament Match Statistics Dheeru & Karra Taniskidou (2017)). For each dataset, we keep the numerical attributes, split it between train and test sets (test size set to ) and train a Random Forest classifier with 200 trees and default parameters from the scikit-learn package. Once again, it is important to note that the considered local surrogates approaches are model-agnostic, and therefore the choice of the classifier does not matter.

We then calculate the average Local Fidelity () of LIME (with default kernel width), LIME-K (LIME with reduced kernel width) and the proposed Local Surrogate approach () in the whole test dataset. The results are shown in Table 1.

The average Local Fidelity of the proposed Local Surrogate approach is significantly higher (between and in AUC score across all datasets) than the one obtained with LIME and LIME-K. Despite an optimized kernel width, LIME thus fails at properly approximating the black-box classifier locally consistently over the whole dataset, resulting in high standard deviation values. On the other hand, LS achieves better Local Fidelity across all datasets with lower standard deviation, thus providing more accurate local explanations for the predictions made by .

moons 0.89 (0.07) 0.96 (0.06) 0.97 (0.03)
cancer 0.86 (0.07) 0.87 (0.07) 0.96 (0.02)
credit 0.67 (0.21) 0.70 (0.18) 0.85 (0.12)
news 0.64 (0.10) 0.67 (0.10) 0.79 (0.07)
tennis 0.85 (0.12) 0.83 (0.13) 0.98 (0.02)
Table 1: Average and standard deviation Local Fidelity scores () for LIME (default), LIME-K and (our proposition) over the half-moons dataset and 4 UCI datasets


In this work, we highlighted the importance of the locality when training local surrogates to provide human-interpretable explanation for a prediction made by a black-box classifier. Features with a local influence can be easily mitigated by the effect of features with a global influence. The challenge lies in defining a relevant sampling method to generate a dataset that allows the surrogate to approximate accurately the black-box decision boundary. We contributed in that direction with the proposition of the Local Surrogate approach. It proposes to center the generation of the surrogate’s training set on the black-box decision boundary and in its immediate neighborhood to ensure a better approximation. We showed improvements provided by our proposition on both toy and UCI datasets in terms of local surrogate fidelity.

Ongoing works focus on the human-interpretability benefits of , in collaboration with experts from the insurance industry. We also plan to ease the setup of the hyper-parameters of the proposed metrics and approach so they are easier to use and take into account situations were they would lead to an inadequate level of locality (e.g. when using a radius  too small to cover the decision border) and thus less relevant explanations.


This work has been done as part of the Joint Research Initiative (JRI) project ”Interpretability for human-friendly machine learning models” funded by the AXA Reseach Fund.




  1. Adler, Philip, Falk, Casey, Friedler, Sorelle A., Rybeck, Gabriel., Scheidegger, Carlos, Smith, Brandon, and Venkatasubramanian, Suresh. Auditing black-box models for indirect influence. Knowl. Inf. Syst., 54(1):95–122, 2018.
  2. Craven, Mark W. and Shavlik, Jude W. Extracting tree-structured representations of trained neural networks. Advances in Neural Information Processing Systems, 8:24–30, 1996.
  3. Dheeru, Dua and Karra Taniskidou, Efi. UCI machine learning repository, 2017. URL
  4. Doshi-Velez, Finale, Kortz, Mason, Budish, Ryan, Bavitz, Chris, Gershman, Sam, O’Brien, David, Schieber, Stuart, Waldo, James, Weinberger, David, and Wood, Alexandra. Accountability of ai under the law: The role of explanation. arXiv preprint arXiv:1711.01134, 2017.
  5. Guidotti, Riccardo, Monreale, Anna, Turini, Franco, Pedreschi, Dino, and Giannotti, Fosca. A survey of methods for explaining black box models. arXiv preprint arXiv:1802.01933, 2018.
  6. Hara, Satoshi and Hayashi, Kohei. Making tree ensembles interpretable. ICML workshop on human interpretability in machine learning (WHI 2016), 2016.
  7. Koh, Pang Wei and Liang, Percy. Understanding Black-box Predictions via Influence Functions. arXiv preprint arXiv:1703.04730, 2017.
  8. Laugel, Thibault, Lesot, Marie-Jeanne, Marsala, Christophe, Renard, Xavier, and Detyniecki, Marcin. Comparison-based inverse classification for interpretability in machine learning. In IPMU, pp. 100–111. Springer Publishing, 2018.
  9. Ribeiro, Marco T., Singh, Sameer, and Guestrin, Carlos. ”Why Should I Trust You?”. Proc. of the 22nd ACM SIGKDD Int. Conf. on Knowledge Discovery and Data Mining - KDD ’16, 2016.
  10. Simonyan, Karen, Vedaldi, Andrea, and Zisserman, Andrew. Deep inside convolutional networks: Visualising image classification models and saliency maps. arXiv preprint arXiv:1312.6034, 2013.
Comments 0
Request Comment
You are adding the first comment!
How to quickly get a good reply:
  • Give credit where it’s due by listing out the positive aspects of a paper before getting into which changes should be made.
  • Be specific in your critique, and provide supporting evidence with appropriate references to substantiate general statements.
  • Your comment should inspire ideas to flow and help the author improves the paper.

The better we are at sharing our knowledge with each other, the faster we move forward.
The feedback must be of minimum 40 characters and the title a minimum of 5 characters
Add comment
Loading ...
This is a comment super asjknd jkasnjk adsnkj
The feedback must be of minumum 40 characters
The feedback must be of minumum 40 characters

You are asking your first question!
How to quickly get a good answer:
  • Keep your question short and to the point
  • Check for grammar or spelling errors.
  • Phrase it like a question
Test description