LIME explains one prediction at a time by approximating a complex black-box model with an interpretable linear model near the example of interest. It is model-agnostic, so the black box can be an ensemble or another machine-learning model. section 9.0 section 9.4.1
The procedure follows a local, weighted approximation:
- Start with the example whose prediction needs explanation and generate nearby surrogate examples by perturbing its features. section 9.4.1
- Query the black-box model on those examples, giving nearby examples greater weight than distant ones. section 9.4.1
- Fit a sparse or otherwise interpretable linear surrogate by minimizing a weighted loss between black-box and surrogate predictions. section 9.4.1
- Read the linear coefficients as local feature contributions, while recognizing that the explanation describes a neighborhood rather than the whole model. section 9.4.1 section 9.6
Explaining a subscription prediction
For an XGBoost marketing model, LimeTabularExplainer can be configured with feature names and categorical features, then applied to a test example. Positive contributions support “will subscribe,” while negative contributions support “won’t subscribe.” section 9.4.1
Figure 9.14 LIME creates a surrogate training set of examples in the locality of the example whose prediction needs to be explained. These examples are further weighted by their distance. This is indicated by the sizes of the surrogate examples, with closer examples getting higher weights (and shown larger). A weighted loss function is used to fit a linear surrogate model, which provides local explanations.
Visualize LIME as a weighted cloud of perturbed examples surrounding the target input, with closer examples exerting greater influence on the fitted linear surrogate. section 9.4.1


