LIME — Explaining One Prediction at a Time
Global feature importance tells you what a model relies on overall, but the question people actually ask is local: why did the model deny this particular loan? LIME answers it with a clever trick — approximate the complicated model with a simple, interpretable one in the small neighborhood around a single prediction. It was the method that popularized model-agnostic local explanations, and understanding how it works (and where it's fragile) is essential interpretability literacy.
Post 3 covered global importance; this post is the first local method (post 1) — explaining an individual prediction. LIME (Local Interpretable Model-agnostic Explanations) is model-agnostic, intuitive, and widely used, and it introduces the core idea behind local explanation that SHAP (post 5) builds on more rigorously.
The idea: locally, even a complex model looks simple
LIME starts from a genuinely clever observation. A complex model’s decision boundary is wildly nonlinear globally — too complicated to describe simply. But locally, in the tiny neighborhood around one specific input, that boundary is approximately simple: you can fit a straightforward linear model that mimics the complex model’s behavior just in that small region. A curve, zoomed in far enough, looks like a straight line.
So to explain why the model predicted what it did for this one input, LIME: 1. Takes the single instance you want to explain. 2. Perturbs it — generates many variations by slightly changing its feature values — and asks the black-box model for its prediction on each. This probes how the model behaves around this point. 3. Fits a simple, interpretable model (usually a weighted linear model) to those perturbed points and their predictions, weighting the perturbations by how close they are to the original instance (nearby variations matter most). 4. Reads the explanation off that simple local model: its coefficients tell you which features pushed this prediction up or down, and by how much.
The result is a local, human-readable explanation — “this loan was denied mainly because of high debt-to-income and a recent missed payment, despite good tenure” — for a single decision from an otherwise opaque model. It’s model-agnostic (it only queries inputs/outputs, so it works on any black box — deep nets, ensembles, anything) and it directly answers the question users and regulators actually ask: why this one?
Why LIME was a breakthrough
LIME mattered because it made local, model-agnostic explanation practical and intuitive:
- It works on any model — because it treats the model as a black box and only needs to query it, LIME explains deep nets, ensembles, and complex pipelines alike, which is exactly the opaque models that most need explaining (post 1).
- It explains individual decisions — the local focus matches real needs: a person denied a loan wants their reason, a doctor wants why this patient was flagged. Global importance (post 3) can’t answer that; LIME can.
- It’s intuitive and visual — the output (a short list of features with their local contributions, often shown as a simple bar chart) is easy for non-experts to grasp, making it a practical communication tool.
- It handles any data type — with appropriate perturbation schemes, LIME explains tabular, text (which words drove the classification), and image (which regions mattered) predictions, giving a unified approach across modalities.
It essentially launched the modern wave of practical post-hoc explanation, and the core idea — approximate the complex model locally with a simple one — is one of the most important concepts in interpretability.
Where LIME is fragile — and why SHAP followed
LIME is powerful but has real, well-documented weaknesses that you must know to use it responsibly — and they’re exactly why SHAP (post 5) was developed:
- Instability. Because LIME relies on random perturbations, running it twice on the same instance can give different explanations. This instability is deeply uncomfortable — an explanation you can’t reproduce is hard to trust, and it’s LIME’s most cited flaw.
- Sensitivity to choices. The explanation depends on how you perturb (the sampling), how you define the local “neighborhood” (the kernel width), and how many samples you draw — and these choices meaningfully change the result, with no obviously correct setting. The explanation is partly an artifact of your parameters.
- The local approximation can be poor. “Locally linear” is an assumption, and in regions where the model’s boundary is sharply curved, the simple surrogate may fit badly and mislead. The explanation is only as good as the local fit, which you don’t always check.
- No guarantees / can be gamed. LIME’s explanations aren’t grounded in a principled theory of fair attribution, and research has shown that adversarially designed models can even fool LIME into hiding biased behavior — a serious concern when explanations are used for auditing.
These aren’t reasons to dismiss LIME — it’s genuinely useful, fast, and intuitive, and remains widely used — but they’re reasons to treat its explanations as suggestive, local approximations rather than exact truths (post 1’s and post 2’s recurring caveat, made concrete). In practice: use LIME for quick, intuitive local insight, but be wary of its instability (run it multiple times, check consistency), validate that the local fit is good, and reach for SHAP (post 5) when you need explanations that are stable and theoretically principled — SHAP was designed precisely to fix LIME’s lack of guarantees by grounding attribution in game theory. LIME is the intuitive pioneer; SHAP is the rigorous successor, and most serious work uses SHAP while owing the core local-explanation idea to LIME.
The throughline: LIME answers the local question “why this prediction?” with a clever idea — a complex model’s boundary is nonlinear globally but approximately linear locally, so you perturb the instance, query the black box on the variations, fit a simple interpretable (linear) model weighted by closeness, and read the per-feature contributions off it. It’s model-agnostic (works on any black box via queries), explains individual decisions (what users/regulators actually ask), is intuitive/visual, and handles tabular/text/image — which made it the breakthrough that launched practical post-hoc explanation. But it’s fragile: unstable (random perturbations → different explanations on reruns — its most cited flaw), sensitive to perturbation/neighborhood/sample choices, a potentially poor local fit in sharply-curved regions, and ungrounded/gameable (no fair-attribution theory; can be fooled to hide bias). So treat LIME explanations as suggestive local approximations, and reach for SHAP (post 5) — designed to fix exactly these gaps with game-theoretic guarantees — when stability and rigor matter.
Key takeaways
- LIME explains a single prediction (local interpretability) via a clever idea: a complex model is nonlinear globally but approximately linear locally, so you can mimic it in a small neighborhood with a simple model.
- Mechanism: perturb the instance into many nearby variations, query the black box on each, fit a weighted linear model (nearby perturbations weighted more) to those predictions, and read which features pushed this prediction up/down from its coefficients.
- It was a breakthrough because it’s model-agnostic (any black box, via queries — explains the opaque models that most need it), explains individual decisions (what a denied applicant or a doctor actually wants, which global importance can’t give), is intuitive/visual, and spans tabular/text/image data.
- It’s fragile: instability (random perturbations → different explanations on reruns — its most cited flaw), sensitivity to perturbation/kernel/sample-size choices (the explanation is partly a parameter artifact), poor local fit where the boundary is sharply curved, and no guarantees / gameable (can be adversarially fooled to hide bias — serious for auditing).
- Treat LIME outputs as suggestive local approximations, not exact truths (run it multiple times, check consistency and local fit); reach for SHAP (post 5) — built to fix LIME’s instability and lack of principle with game-theoretic grounding — when you need stable, rigorous explanations. LIME is the intuitive pioneer, SHAP the rigorous successor.
Further reading
- Explainable artificial intelligence — local surrogate explanations
- Surrogate model — approximating a complex model with a simple one