Phase 3: Explainability & Transparency · 40 min · Python · LIME · scikit-learn
LIME — Local Interpretable Model-Agnostic Explanations
SHAP explains with game theory. LIME explains with a local surrogate.
Hiring signal: LIME appears alongside SHAP in most RAI postings. Being able to compare LIME and SHAP explanations on the same prediction — and explain when they differ — shows depth in explainability tooling.
What you will learn
- Explain LIME's local surrogate model approach
- Generate LIME explanations for individual predictions
- Compare LIME and SHAP explanations on the same predictions
- Articulate LIME's limitations: instability and sampling sensitivity
The Problem
SHAP is powerful but can be slow for non-tree models (KernelExplainer) and sometimes produces explanations that are hard to explain to non-technical stakeholders. LIME offers an alternative approach: instead of computing exact Shapley values, it fits a simple, interpretable model (like a linear regression) locally around the prediction being explained.
How LIME Works
- Take the instance you want to explain
- Generate perturbed samples around it (slightly modified versions)
- Get the model's predictions for all perturbed samples
- Weight the samples by proximity to the original instance
- Fit a simple linear model on the weighted samples
- The linear model's coefficients are the explanation
The result is a set of feature weights that show how each feature contributed to this specific prediction — similar to SHAP's local explanation but using a different mathematical approach.
Unlock the full lesson
You've read the first 2 sections. The rest of this lesson covers SHAP vs. LIME: When They Differ, Building the LIME Module, What's Next — plus a hands-on lab, quiz, and project artifact.
Create a free account to unlock Phase 0 and Phase 1 of every course — no credit card.
Browse all courses · View pricing · DeVenture Academy