Explainability Overview
Opening black boxes without opening the weights
Explainability answers why a model makes its decisions: global (what the model learned overall) and local (why this prediction). It covers feature importance, SHAP, LIME, surrogates, PDPs and counterfactuals — each with different guarantees and costs.
What you will learn
- Distinguish global vs local explanations
- Contrast inherently interpretable vs post-hoc models
- Match a question (why trust? why reject? which feature?) to a technique
What is this?
Explainability refers to methods that describe what a model does. Global explanations summarize model behavior over the whole dataset (feature importance, PDPs, surrogate trees); local explanations explain a single prediction (SHAP values, LIME, counterfactuals). Some models are inherently interpretable (linear, trees, rules); black boxes get post-hoc explanations. The right tool depends on the question: audit a feature, justify a decision, debug a drift, or serve a regulation.
Why do you need it?
- Regulatory and risk contexts (credit, health, insurance) demand decisions you can justify.
- Debugging: explaining a bad cluster of predictions reveals data leaks and encoding bugs.
- Trust: stakeholders (and users) act on models they can verify.
- Feature attribution quantifies what the model actually relies on — catching shortcut learning.
Mental model
A doctor explaining your diagnosis
A model explaining its prediction
You don't need the doctor to hand over their textbook chapters; you want to know which symptoms and tests drove the verdict. Local explanation = 'these three findings drove this diagnosis'. Global explanation = 'across 10,000 patients, fever and rash are the strongest drivers'.
How it works
- Inherently interpretable: linear coefficients, tree splits, rule lists — readable by construction.
- Global post-hoc: permute each feature and measure the drop in performance → importance.
- Local attribution: SHAP decomposes a prediction into per-sample additive contributions.
- Local surrogate: LIME fits a small interpretable model around a single prediction.
- What-if & counterfactual: perturb features and ask 'how much change to flip the outcome?'.
Explainability questions and their tools.
In production
- Credit scoring: SHAP waterfall for adverse-action letters and audit trails.
- Medical triage: explaining model flags before clinician review.
- Churn systems: segmenting WHO is leaving from WHY via global importance.
Best practices
- Define WHO needs the explanation (auditor, user, engineer) before picking a tool.
- Pair global importance with local explanations — each alone over-simplifies.
- Sanity-check explanations against domain knowledge; surprising attributions surface bugs.
- Report uncertainty: SHAP approximations and LIME samples have variance.
Common mistakes
- Reading correlation-heavy importance (colinear features) as causal.
- Using a local explanter to describe the whole model.
- Trusting black-box attributions without cross-checking with a second method.
- Explaining a proxy (training metric) instead of the production target.
Common issues
SHAP and permutation importance disagreeCollinear features + different attribution semantics
Note that SHAP splits credit fairly across correlated features while permutation drops them jointly; report both with a collinearity warning.
Explanations unstable across samplesLocal surrogate/approx sampling noise or high variance
Grow LIME sample counts, fix seeds, aggregate repeated explanations before trusting a single one.
Importance dominated by one useless featureFeature leak (id leak or target leakage)
Investigate the feature pipeline; check the feature's profile vs label.
Debugging tips
- Run two independent explainers (e.g. SHAP + permutation) — disagreement flags fragile attributions.
- Explain a handful of known-good predictions first; the tools should confirm your intuition.
- Check leakage: high importance for a personal-ID or date feature often means a leak.
- Stress with duplicates: feature importance that spikes on near-duplicate rows signals collinearity.
Interview checkpoint
Quick quiz
Explaining a single rejected loan application is:
Linear regression coefficients are inherently interpretable.