Lion Cipher Lab
Explain ML model predictions with SHAP
- AI Security
- Intermediate
- ~60 min
- Free · no account required
Why it matters
Most machine-learning models are black boxes: you feed in numbers, a prediction comes out, and nothing tells you why. That is fine until a model decides who gets a loan, which transaction is flagged as fraud, or which login is an intruder -- and then 'the computer said so' is not an answer anyone can accept. Interpretability is the discipline of making a model explain itself, and it is not a nice-to-have; it is what makes four everyday jobs possible. Debugging: when a model is wrong you cannot fix what you cannot see, and an explanation shows you the feature that misled it. Fairness: the only…
What you'll learn
- what model interpretability (explainability) means and why a black-box decision needs an explanation
- the four everyday reasons to explain a model: debugging, fairness, trust, and accountability
- training a simple classifier (RandomForest) on a built-in labeled dataset with scikit-learn
- what a SHAP value is: one number saying how much a single feature pushed one prediction up or down
- the idea of a base value (the model's average output) that SHAP values add onto
- producing a GLOBAL explanation: ranking which features matter most across all predictions (mean absolute SHAP)
- reading a SHAP summary (beeswarm) plot
- producing a LOCAL explanation: a per-prediction, line-by-line reason for one specific case, plus a waterfall plot
- the honest limits: an explanation shows what the model used, not ground-truth cause, and explainability is a tool for fairness, not a guarantee of it
Steps in this lab
- Why a black box needs an explanation
- The words you need: SHAP value and base value
- Install scikit-learn, shap, and matplotlib
- Train a simple classifier on a built-in dataset
- Compute SHAP values for the trained model
- Global explanation: which features matter overall
- Local explanation: why THIS one prediction
- The honest limits: what an explanation does and does not prove
- What you can now do that most people can't