LIME (Local Interpretable Model-agnostic Explanations) is an algorithm that explains individual predictions of any black-box classifier by learning an interpretable model, such as a sparse linear model or decision tree, on a locally perturbed neighborhood around the prediction instance. It provides feature attribution by weighting these perturbed samples by their proximity to the original input, revealing which features most influenced that specific decision.
Glossary
LIME (Local Interpretable Model-agnostic Explanations)

What is LIME (Local Interpretable Model-agnostic Explanations)?
LIME explains the prediction of any classifier by approximating it locally with an interpretable model.
The technique is model-agnostic, meaning it treats the original model as a black box and requires no internal access to gradients or architecture. LIME generates explanations by creating a new dataset of permuted instances, obtaining their predictions, and fitting a glass-box surrogate that is inherently interpretable. This local fidelity ensures the explanation is faithful to the model's behavior in the immediate vicinity of the prediction, though it does not provide a global understanding of the entire model.
Core Characteristics of LIME
LIME explains individual predictions by creating a locally faithful, interpretable surrogate model around the specific instance being analyzed.
Local Fidelity
LIME does not attempt to explain the entire global behavior of a black-box model. Instead, it focuses on local fidelity, generating an explanation that is valid in the immediate neighborhood of the prediction being analyzed.
- The explanation is derived from a simpler, interpretable model (e.g., a sparse linear model) trained on perturbed samples.
- Samples are weighted by their proximity to the original instance, ensuring the surrogate model accurately mimics the complex model's decision boundary only in that specific local region.
Model-Agnostic Architecture
The technique treats the original model as a complete black box, making it model-agnostic. It requires no knowledge of the internal weights, gradients, or architecture.
- LIME operates solely by observing the relationship between inputs and outputs of the model
f. - This property allows a single explanation interface to be applied uniformly across different model types, from deep neural networks and gradient-boosted trees to random forests and support vector machines.
Interpretable Data Representations
Regardless of the original feature space used by the model, LIME requires an interpretable representation that is understandable to humans.
- For text classification, the interpretable representation is the binary presence or absence of individual words.
- For image classification, it is the presence or absence of contiguous super-pixels (segments).
- The explanation is presented as a weighted list of these human-friendly features that contributed most to the prediction.
Sparse Linear Explanations
To ensure the explanation is simple enough for a human to process, LIME applies a complexity penalty to the surrogate model.
- The objective function minimizes the weighted least squares loss while constraining the number of non-zero weights (using L1 regularization or a fixed K-feature budget).
- This produces a sparse explanation, highlighting only the most critical super-pixels or words that drove the decision, rather than overwhelming the user with every feature.
Perturbation Sampling Strategy
The local neighborhood is generated by drawing perturbed samples around the instance of interest.
- For tabular data, this involves drawing from a normal distribution centered on the instance.
- For text, it involves randomly removing words to see how the prediction changes.
- For images, it involves turning super-pixels on and off. The fidelity of the explanation is directly tied to the number of samples generated; more samples yield a more accurate local approximation of the decision boundary.
Submodular Pick for Global Insight
While LIME is inherently local, the framework includes the Submodular Pick (SP-LIME) algorithm to select a representative set of instances for global understanding.
- SP-LIME treats explanation selection as a submodular optimization problem to maximize feature coverage.
- It picks a diverse, non-redundant set of individual explanations, giving a user a high-level overview of the model's behavior by showing which important features recur across a representative sample of predictions.
Frequently Asked Questions
Clear, concise answers to the most common technical and conceptual questions about Local Interpretable Model-agnostic Explanations (LIME), a foundational technique for auditing black-box model predictions.
LIME (Local Interpretable Model-agnostic Explanations) is a technique that explains the prediction of any classifier by approximating it locally with an interpretable model, such as a sparse linear model, around the prediction. The core mechanism involves three steps: first, LIME generates a new dataset of perturbed samples by randomly altering the original input instance. Second, it obtains the black-box model's predictions for all these perturbed samples. Third, it trains a simple, inherently interpretable surrogate model (like a linear regression or decision tree) on this local dataset, weighting the samples by their proximity to the original instance. The coefficients or feature weights of this local surrogate model then serve as the explanation, revealing which features were most influential for that specific prediction. This locality is crucial, as it acknowledges that a model's global decision boundary may be highly complex, but the boundary around a single point can often be approximated by a simple, linear function.
LIME vs. SHAP: Key Differences
A technical comparison of two dominant post-hoc, model-agnostic explanation frameworks: LIME's local surrogate approach versus SHAP's game-theoretic Shapley value approach.
| Feature | LIME | SHAP |
|---|---|---|
Core Principle | Local surrogate modeling via sparse linear approximation | Game-theoretic Shapley values from cooperative game theory |
Theoretical Foundation | Fidelity-interpretability trade-off | Axiomatic (efficiency, symmetry, dummy, additivity) |
Explanation Scope | Local only (single prediction) | Local and global (via aggregation of local values) |
Model Agnosticism | ||
Output Type | Feature weights for a local linear model | Additive feature importance scores (Shapley values) |
Consistency Guarantee | ||
Computational Cost | Low to moderate | High (exact computation is NP-hard; relies on approximations) |
Handles Feature Correlation | Struggles; perturbed samples may be unrealistic | Handles via conditional expectation (KernelSHAP) or interventional (TreeSHAP) |
Stability of Explanations | Lower; random perturbation sampling introduces variance | Higher; deterministic given a background dataset |
Primary Variants | Tabular LIME, Image LIME, Text LIME | KernelSHAP, TreeSHAP, DeepSHAP, GradientSHAP |
Interpretable Representation | User-defined (e.g., super-pixels, bag-of-words) | Feature-level (raw or simplified input space) |
Global Feature Importance | Not directly provided | Mean absolute Shapley value across all predictions |
Additive Feature Attribution | ||
Unified Framework Status | Standalone method | Unifies LIME, DeepLIFT, and Layer-wise Relevance Propagation |
Best Use Case | Rapid prototyping and non-technical stakeholder demos | Regulatory compliance, audit trails, and high-stakes decisions |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Core concepts and complementary techniques that contextualize LIME within the broader landscape of local, model-agnostic interpretability.
SHAP (SHapley Additive exPlanations)
A game-theoretic framework that assigns each feature an importance value for a particular prediction. Unlike LIME's heuristic sampling, SHAP uses Shapley values to guarantee a fair distribution of the prediction among features. While LIME is faster to compute, SHAP provides stronger theoretical consistency and is often preferred for high-stakes audits.
Anchors
A direct successor to LIME that provides high-precision, human-readable rules called anchors. These IF-THEN statements sufficiently 'anchor' a prediction locally, ensuring changes to other feature values do not alter the outcome. Anchors solve LIME's primary weakness: the inability to define a precise coverage region where the explanation is valid.
Counterfactual Explanations
Explanations that identify the minimal change to an input feature required to flip a model's prediction. While LIME explains why a decision was made, counterfactuals explain how to change it. For example: 'Your loan was denied. If your income were $5,000 higher, it would have been approved.'
Global Surrogate Models
An interpretable model (e.g., a shallow decision tree) trained to approximate the predictions of an entire black-box model. LIME is a local surrogate, explaining a single prediction. A global surrogate explains all predictions at once, trading local fidelity for a comprehensive, high-level view of model behavior.
Perturbation-Based Interpretability
The foundational category to which LIME belongs. These methods probe a black-box model by systematically altering inputs and observing output changes. Key techniques include:
- LIME: Local linear approximations via sampling
- Permutation Feature Importance: Global ranking via feature shuffling
- Anchors: Rule extraction via multi-armed bandits
Sparse Linear Models
The interpretable 'white-box' model at the heart of LIME. By fitting a Lasso regression or similar sparse linear model on perturbed samples, LIME identifies the few features that most influence a prediction. The sparsity constraint ensures the explanation remains human-comprehensible, avoiding cognitive overload from dozens of features.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us