{
  "id": "lime",
  "title": "Local Interpretable Model-Agnostic Explanations",
  "lang": "en",
  "source_lang": "en",
  "summary": "Local Interpretable Model-Agnostic Explanations (LIME) explains individual model predictions by fitting simple, interpretable approximations to model behavior around a selected input.",
  "category": "computer-science",
  "subcategory": "artificial-intelligence",
  "type": "concept",
  "aliases": [
    "LIME",
    "Local Interpretable Model-Agnostic Explanation"
  ],
  "generated_at": "2026-11-04",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/lime/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/lime/",
      "json": "https://aiwiki.page/zh/lime.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "Local Interpretable Model-Agnostic Explanations (LIME) is a method in explainable artificial intelligence that explains an individual prediction by approximating a complex model with a simpler model in a neighborhood of the input. It generates perturbed inputs, obtains the original model’s predictions for them, and fits an interpretable model that gives greater weight to samples considered closer to the input being explained. The resulting explanation typically identifies a small set of features that support or oppose a particular prediction. LIME describes the model’s behavior under the chosen perturbations; it does not establish why an outcome occurs in the real world."
    },
    {
      "heading": "Origin and purpose",
      "text": "Marco Tulio Ribeiro, Sameer Singh, and Carlos Guestrin introduced LIME in their 2016 paper, “Why Should I Trust You?”: Explaining the Predictions of Any Classifier. The work addressed a practical problem in machine learning: a model can achieve strong predictive performance while relying on patterns that users do not expect or consider appropriate.\n\nLIME separates the model used for prediction from the model used for explanation. The predictor may be a random forest, a support vector machine, or an artificial neural network. The explanatory model is deliberately simpler, commonly a sparse linear model.\n\nThree terms describe its intended scope:\n\n- Local: it approximates behavior around one selected input, rather than throughout the entire input space.\n- Interpretable: it expresses the approximation using a representation and model intended to be understandable to a person.\n- Model-agnostic: it primarily requires the ability to query predictions, rather than access to the predictor’s architecture, parameters, or gradients.\n\nModel-agnosticism does not mean that no adaptation is necessary. Input preprocessing, perturbation rules, distance measures, and explanation displays must still be appropriate to the data and task."
    },
    {
      "heading": "Mathematical formulation",
      "text": "Let \\(f\\) be the model being explained and \\(x\\) the input of interest. For classification, \\(f(x)\\) can denote the score or predicted probability for a selected class. For regression, it can denote the predicted numerical value.\n\nThe original input may have a different representation from the explanation. For example, a text classifier may process dense vectors, while an explanation describes the presence or absence of words. Let \\(x'\\) denote the interpretable representation, and let \\(h_x(z')\\) map a perturbed interpretable input \\(z'\\) back into an input that the original model can process.\n\nLIME expresses the explanation as an optimization problem:\n\n\\[\\xi(x)=\\arg\\min_{g\\in G} \\left[ \\mathcal{L}(f,g,\\pi_x)+\\Omega(g) \\right].\\]\n\nHere:\n\n- \\(G\\) is a family of interpretable models.\n- \\(\\mathcal{L}\\) is a measure of disagreement between the original model and the explanation model.\n- \\(\\pi_x\\) assigns locality weights to perturbed samples.\n- \\(\\Omega(g)\\) penalizes explanation complexity.\n\nA common choice is a weighted squared-error loss function:\n\n\\[\\mathcal{L}(f,g,\\pi_x) = \\sum_{i=1}^{N} \\pi_x(z_i) \\left[ f(z_i)-g(z_i') \\right]^2, \\qquad z_i=h_x(z_i').\\]\n\nThe locality weights can be defined by an exponential kernel, for example:\n\n\\[\\pi_x(z)= \\exp\\left(-\\frac{D(x,z)^2}{\\sigma^2}\\right),\\]\n\nwhere \\(D\\) is a distance measure and \\(\\sigma\\) controls the neighborhood’s width. Implementations may use related kernel conventions, so the numerical meaning of the width depends on the precise definition.\n\nA frequently used surrogate is a sparse linear model:\n\n\\[g(z')=\\beta_0+\\sum_{j=1}^{p}\\beta_j z_j'.\\]\n\nSparsity limits the number of displayed features. It may be imposed through feature selection, a constraint on the number of nonzero coefficients, or regularization. The optimization formulation describes the fidelity–complexity trade-off; practical implementations commonly approximate it through separate feature-selection and fitting steps."
    },
    {
      "heading": "Explanation procedure",
      "text": "A typical LIME explanation involves five stages.\n\nChoosing the target and representation\n\nThe explanation concerns a specified output, such as the probability assigned to one class. This distinction matters in multiclass classification: a feature can support one class while opposing another.\n\nThe interpretable representation defines the units of explanation. These might be words, image regions, numerical variables, or intervals of numerical variables. They need not match the predictor’s internal features.\n\nGenerating perturbations\n\nLIME samples modified versions of the input. Depending on the application, this can involve removing words, masking image regions, or changing tabular feature values.\n\nThese perturbations define the artificial dataset on which the explanation is fitted. Their distribution is therefore part of the explanation method, not merely an implementation detail.\n\nQuerying the original model\n\nThe predictor evaluates every perturbed input. Its outputs become the targets used to train the surrogate.\n\nThis usually requires many predictions for each explanation. Where model access is provided through an application programming interface, query latency, usage limits, and cost can be important.\n\nWeighting and fitting\n\nPerturbations receive weights according to their distance from the original input. LIME then fits a simple model to reproduce the predictor’s outputs, emphasizing nearby samples and restricting explanation complexity.\n\nThe neighborhood width, number of samples, number of retained features, and fitting method are consequential hyperparameters.\n\nPresenting the explanation\n\nThe explanation commonly appears as a ranked feature list, a bar chart, highlighted words, or highlighted image regions. Positive and negative coefficients indicate directions of association with the selected model output within the fitted local approximation.\n\nA coefficient is not automatically a globally valid feature importance. Its meaning depends on the representation, scaling, neighborhood, other included features, and target output."
    },
    {
      "heading": "Treatment of different data types",
      "text": "Tabular data\n\nFor tabular prediction, perturbations change numerical and categorical variables. The resulting explanation may use original variables or conditions such as “income falls within this interval.”\n\nContinuous features are often discretized for presentation, although implementations also support explanations without discretization. Sampling may use statistics estimated from training data, while categorical values may be sampled according to observed frequencies.\n\nDistance calculations are sensitive to feature scaling. In addition, independently perturbing variables can produce implausible combinations when the variables are correlated or constrained. A model’s behavior on such combinations may differ from its behavior on realistic observations.\n\nText\n\nIn natural language processing, a common LIME representation marks whether words are present. Perturbed documents are generated by removing selected words, and the surrogate estimates which words influence a selected prediction.\n\nThis representation can be useful even when the predictor uses a transformer or another complex architecture. However, removing words can alter grammar, meaning, and context. Word-level explanations may also differ from a model’s internal tokenization, especially when it processes subword units.\n\nImages\n\nFor image classification, LIME commonly partitions the image into superpixels, or groups of neighboring pixels. Perturbations retain or mask these regions, and the surrogate assigns weights to their presence.\n\nThe explanation depends on how the image is segmented and on the masking baseline. Replacing a region with a uniform color, a regional average, or another baseline creates different model inputs. A highlighted region therefore indicates influence under a particular masking procedure, not necessarily recognition of a meaningful object."
    },
    {
      "heading": "Fidelity and interpretation",
      "text": "The central quality criterion is local fidelity: how well the surrogate reproduces the original model’s behavior in the chosen neighborhood.\n\nThis differs from the predictor’s accuracy. A predictor can be wrong about an outcome while LIME accurately describes its local behavior. Conversely, an accurate predictor can receive a poor explanation if the surrogate fails to approximate it.\n\nSeveral distinctions are important:\n\n- Local fit is not global validity. An explanation for one observation need not apply to another.\n- Agreement at one point is insufficient. Matching \\(f(x)\\) does not establish agreement across nearby inputs.\n- Surrogate fit is distribution-dependent. Strong agreement on generated perturbations does not necessarily imply agreement on naturally occurring cases.\n- Interpretability is audience-dependent. A short feature list is not necessarily meaningful to every user.\n\nLIME is a post hoc explanation technique: it explains an already fitted model without changing that model. It does not reveal a unique internal reasoning process."
    },
    {
      "heading": "Limitations and robustness",
      "text": "Sampling instability\n\nLIME is a randomized algorithm. Different perturbation samples can produce different selected features or coefficients, especially when features have similar explanatory power or the model’s local behavior is nonlinear.\n\nFixing a random seed makes a particular configuration reproducible, but does not establish that its explanation is stable under other samples or settings.\n\nDependence on neighborhood design\n\nA narrow neighborhood can contain too little useful variation. A broad neighborhood may combine distinct behavioral regimes that a simple surrogate cannot represent well. Distance in an input representation also need not correspond to semantic similarity.\n\nAccordingly, there is no universally appropriate neighborhood width or distance measure.\n\nUnrealistic perturbations\n\nPerturbations can place inputs outside the distribution encountered during model training or deployment. This creates a form of distribution shift between the explanation samples and realistic data.\n\nThe problem is particularly important when inputs have strong dependencies, such as correlated measurements, grammatical structure, or spatial relationships. The surrogate may faithfully reproduce behavior on artificial inputs while poorly characterizing behavior on plausible ones.\n\nCorrelated features and interactions\n\nWhen features are strongly correlated, attribution among them may be ambiguous. A sparse surrogate can select one feature and omit another that carries similar information.\n\nA linear surrogate also cannot directly express all interactions. If the predictor’s output depends on combinations of features, individual coefficients can hide or simplify that dependence.\n\nNo causal guarantee\n\nLIME’s perturbations are changes to model inputs, not necessarily valid interventions on the underlying system. Its coefficients do not establish causal relationships or prove that changing a real-world variable would produce the indicated outcome.\n\nSusceptibility to misleading explanations\n\nA model can behave differently on explanation-time perturbations than on ordinary inputs. If these inputs are distinguishable, a deliberately constructed predictor may yield reassuring explanations while retaining unwanted behavior on realistic data. Model-agnostic access therefore does not guarantee that an explanation is resistant to manipulation."
    },
    {
      "heading": "Related approaches and extensions",
      "text": "SHapley Additive exPlanations (SHAP) also provides feature-attribution explanations, but connects attribution to a game-theoretic framework. Kernel SHAP uses a weighted regression construction with a particular weighting scheme and constraints. Standard LIME instead emphasizes the fit of an interpretable model in a chosen neighborhood. Despite similarities in their outputs, the methods can assign different meanings and values to feature contributions.\n\nSubmodular Pick LIME, introduced alongside LIME, selects a small set of instance-level explanations intended to cover diverse important features with limited redundancy. It supports inspection of a model through representative examples, but does not transform each local surrogate into a globally valid explanation.\n\nLIME is also distinct from knowledge distillation, which typically trains a smaller model to reproduce a larger model over a broader distribution. LIME’s defining goal is an interpretable approximation focused on a particular prediction."
    },
    {
      "heading": "Applications and evaluation",
      "text": "LIME is used for model debugging, inspection of unexpected predictions, and communication of local model behavior. Explanations can reveal reliance on background regions, incidental words, or variables that appear unrelated to the intended task. Such patterns can motivate investigation of data leakage or dataset artifacts, but an explanation alone does not establish their presence.\n\nEvaluation can examine surrogate agreement on additional neighborhood samples, repeated-run stability, sensitivity to perturbation settings, and performance on realistic rather than solely synthetic inputs. Human evaluation addresses a separate issue: whether explanations help users understand model behavior without encouraging unwarranted confidence. Predictive accuracy, explanation fidelity, and usefulness to people are distinct properties."
    }
  ],
  "links": [
    "explainable-artificial-intelligence",
    "machine-learning",
    "random-forest",
    "support-vector-machine",
    "artificial-neural-network",
    "loss-function",
    "linear-regression",
    "feature-selection",
    "regularization",
    "multiclass-classification",
    "application-programming-interface",
    "hyperparameter",
    "training-data",
    "feature-scaling",
    "natural-language-processing",
    "transformer-architecture",
    "tokenization",
    "image-classification",
    "randomized-algorithm",
    "distribution-shift",
    "causation",
    "shap",
    "knowledge-distillation",
    "data-leakage"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}