AIToday
Qiita 機械学習Published: Nov 11, 2026, 16:00 JST

SHAP and LIME: a practical guide to opening up AI's black box

Send on LINE
SHAP and LIME: a practical guide to opening up AI's black box

3 Key Points

  1. What happened

    The guide walks through SHAP (which distributes each feature's contribution to a prediction using game-theory Shapley values) and LIME (which approximates a single prediction locally with a simple model), with Python code on a breast-cancer Random Forest classifier.

  2. Why it matters

    The author warns that SHAP and LIME chart how a model decided, not real-world causality — so bias in the training data gets visualized as-is, and teams need an audit-and-feedback cycle covering correlations, compute cost, and production latency.

Not sure about something? Ask the AI

Questions and answers are published on this page.

Summaries like this, every morning.

Context & Analysis

The guide frames explainability as an operational problem as much as a technical one. It points to credit scoring, medical diagnosis, e-commerce recommendations, and autonomous driving as areas where models are already embedded, and notes that under rules like Europe's GDPR, automated decisions increasingly come with a right to explanation. That shifts the burden onto engineers: when a loan application is rejected or a diagnosis is issued, someone has to justify the result, audit it for bias by race or gender, and stand behind it with customers and regulators.

The piece then separates the two tool families by use case. SHAP, built on Shapley values from game theory, spans both a model-wide importance view and individual predictions, with a TreeExplainer optimized for tree-based models. LIME instead samples around a single point and fits a simple local model, trading global insight for speed and intuition. The caveats are where the practical value sits: model-agnostic methods slow down sharply on large datasets, strong correlations between features can skew apparent importance, and per-inference explanations strain production latency — so the guide recommends precomputed summaries or rule-based substitutes when explanations must be served live.

FAQ
What is the difference between SHAP and LIME?
SHAP gives both a model-wide feature-importance view and a fair per-prediction breakdown based on Shapley values. LIME samples around one data point and approximates the model locally, offering an intuitive case-by-case explanation.
Why does the guide say visualization alone is not enough?
Because SHAP and LIME show how the model judged, not real-world causal relationships. If the training data carries bias, the explanation will display that bias unchanged, so an audit and feedback cycle is needed.
Can SHAP and LIME run in real time in production?
Calculating SHAP or LIME values per inference tends to become a latency bottleneck. The guide suggests using them mainly offline for development, validation, or post-hoc monitoring, or precomputing summaries.
Qiita 機械学習Read Original Article
Send on LINE

AI news that matters for your work, delivered every morning.

Pick your industry and the AI tools you use, and get news related to your work every day.

Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →

Ask AI

Ask AI anything about this article. The AI reads this article, earlier AIToday articles, and Wikipedia, and cites its sources. Q&As are published on this page for other readers too.

Questions and answers are published on this page.

Next articleOpenAI AI pipeline patches 948 Linux kernel flaws