Computational scientists who need to explain a complex machine learning model face a deceptively simple choice between two dominant techniques: LIME and SHAP. The short answer is that the right pick depends on three questions. Do you need to explain one prediction or the model's overall behavior? Is your model a tree ensemble? And how much compute can you afford? LIME delivers fast, local explanations for essentially any black-box model but produces unstable results across repeated runs, according to a comparative analysis of the two methods published in IEEE. SHAP, grounded in cooperative game theory, provides consistent local and global feature attributions—but exact computation is exponential in the number of features, unless you use a specialized variant such as TreeSHAP, which runs in polynomial time for tree-based models.

LIME: Local Interpretability Through Surrogate Models

LIME—Local Interpretable Model-agnostic Explanations—answers a narrow question: why did the model make this prediction for this instance? Rather than trying to open the black box, it builds a small, interpretable surrogate model—typically a linear approximation—around the specific point being explained. The method perturbs the instance, observes how the complex model responds, and fits the simple model to that local behavior. The surrogate's coefficients then serve as the feature explanation.

Because it only queries the model as an oracle, LIME works with any algorithm. In a systematic review of LIME and SHAP applications in Alzheimer's disease detection published in PMC, researchers noted that LIME, "a model-agnostic approach, provided local explanations for AD classification on MRI images"—no retraining or architectural knowledge required. This flexibility is LIME's core practical asset for scientists working with heterogeneous models, from imaging pipelines to genomics classifiers.

The cost is two-fold. First, because the surrogate is local and linear, it cannot account for non-linear dependencies among features locally—a limitation explicitly noted in a perspective on SHAP and LIME posted on arXiv. Second, because explanations depend on random instance perturbations, LIME's output is not very stable across repeated tests; the same prediction can yield different feature rankings on each run. That instability matters in scientific settings where reproducibility of the explanation itself is part of the claim.