f(x) = E[f(X)] + Σφᵢthe whole library · exact for Tree & Linear, approximate for Kernel
3-line workflowExplainer(model, X) → explainer(X) → plots.waterfall(sv[0])
use the modern APIexplainer(X) returns an Explanation with base_values attached · .shap_values() doesn't
TreeExplainer is EXACTand fast · Kernel is approximate and slow — verified 85.42 vs 93.67 on the same row
global = mean(|φ|)never mean(φ) — it cancels to ≈0 and ranks your top feature as trivial
binary clf → 3-D values(n, features, 2) · slice sv[..., 1] for the positive class
XGB/LGBM → LOG-ODDSφ does NOT sum to predict_proba · sigmoid(Σ) does · sklearn RF gives probability
E[f(X)] movesit's computed from the BACKGROUND set · change it and every φ changes
shap.sample(X, 100)always summarise the background for Kernel/Deep, or it hangs
waterfall = one rowsv[0] · beeswarm/bar = the whole matrix sv
beeswarm: x=φ, colour=valuered cloud on the right = "high values push the prediction up"
scatter = dependenceplots.scatter(sv[:, "age"], color=sv) reveals non-linearity and interactions
force needs initjs()or you get a blank cell in the notebook
SHAP is not causalit says how the MODEL used a feature, not what would happen if you changed it
correlated features split creditnear-duplicates share attribution — interpret them as a group
just need a ranking?permutation_importance is one line and fewer assumptions · SHAP is for per-row decomposition