Explainable Scoring at Scale: From SHAP Values to Useful Evidence
Before you start: Shapley values and distributed scoring contracts.
An explanation should answer a concrete question: why did this model give this row this score relative to its baseline? It should also let a reviewer inspect the underlying evidence. SHAP contributions support the first question; feature values, provenance, and reference statistics support the second. A production explanation needs both.
| Known features | Value v(S) |
|---|---|
| None | 0.10 |
| A | 0.40 |
| B | 0.20 |
| A and B | 0.80 |
Start with the output being explained
For an additive explanation, $f(x)=\phi_0+\sum_j\phi_j$. The baseline $\phi_0$ and all contributions must be in the same output space as f. If f is a binary classifier’s raw logit, adding contributions reconstructs the logit. Apply sigmoid after summing to recover the probability; do not call each logit contribution a probability-point change.
For example, baseline logit −2 and contributions +1.2,+0.8 reconstruct logit 0, hence probability 0.5. The baseline probability is sigmoid(−2)≈0.119. The probability change is about 0.381, not 2.0. A probability-output explainer is a different decomposition and must be supported by the model/explainer configuration.
The baseline encodes a comparison population
An interventional explanation integrates missing features against a background dataset under its defined intervention convention. A tree-path-dependent explanation uses tree path statistics to account for missing features. These approaches make different assumptions about feature dependence. Correlated features can therefore receive different allocations without a bug in the summation.
Choose a background appropriate to the question: a representative training population, a peer group, or a fixed reference cohort. Changing it changes the question. Version the background and keep it stable for comparisons. If different tenants receive different backgrounds, explain why the resulting contributions are not directly interchangeable.
Tree structure makes exact calculations practical
TreeSHAP uses the tree’s branch structure and path bookkeeping to account for feature coalitions efficiently. It is not just “subtract the prediction before and after each visited split.” A missing feature may route expectation through multiple branches, and repeated features on a path need careful treatment. The SHAP foundations chapter explains how tree structure changes the computation.
For ensembles, add contributions across trees in the model output space, including the appropriate base offset. Validate the explainer against a brute-force coalition calculation on tiny models where feasible. This catches assumptions that are obscured by a large production ensemble.
Explain the rows and features the product needs
Scoring every row and computing full explanations for every row are different workloads. If only a small queue needs detailed inspection, score the full population first, then explain selected rows plus an audit sample. This reduces compute while preserving visibility into non-alert cases. If every score requires an explanation, batch it and measure the cost separately.
A validation contract for explanations
| Invariant | Required evidence |
|---|---|
| Additivity | Baseline + all contributions matches the declared output within tolerance |
| Feature alignment | Contribution index matches the feature schema and raw value |
| Background identity | Version and sampling rule are recorded |
| Completeness | Omitted displayed features are aggregated into an “other” contribution |
| Provenance | Raw evidence links resolve to the scored snapshot |
| Stability | Frozen rows do not change unexpectedly after a dependency update |
An attribution is not a causal claim. “Permission count raised the model score” does not prove that reducing permissions would reduce actual risk. Counterfactual interventions require a model of which feature combinations are feasible and what outcomes would follow. Keep explanatory wording tied to the model computation.
Check your understanding: Can you sigmoid each SHAP logit contribution and add the results?
No. Sigmoid is nonlinear. Sum the baseline and contributions in logit space first, then transform the total, or use a supported probability-space explanation with its own assumptions.
Sources and further reading
- SHAP TreeExplainer documentation — Output units, background data, and feature-dependence assumptions.
- Lundberg et al.: from local explanations to global understanding — Tree-based explanations and their interpretation.