Skip to content
ML Academy

Classical ML, validation, metrics, interpretation, debugging · insight-1151

State the background data behind SHAP values, because it defines what a feature value is compared with

Evidence type
documented fact
Difficulty
medium
Roles
Data scientist, ML engineer
Industries
banking, insurance, cross-industry

Summary: situation, action, reason, boundary

  1. Situation

    SHAP bars for a tree model are presented as how much each feature matters, with no mention of the reference rows.

  2. Action

    Record feature_perturbation and the background sample (size and how it was drawn), choose the model output scale deliberately, and recompute with a second background to check stability.

  3. Reason

    SHAP values plus the expected value equal the model output; the expected value is the average prediction over the background, so the reference defines the baseline.

  4. Boundary

    TreeExplainer on boosted trees and forests in reports, audits and dashboards.

Symptom or risk

Attributions are differences from an expected value computed over a reference distribution; a different background, or the training-leaf counts in path-dependent mode, changes the numbers and the story.

Exceptions

For a purely relative ranking of features in one fixed analysis, conclusions are often stable across reasonable backgrounds, which you should verify.

Trade-offs

Interventional mode needs a background and more compute; path-dependent needs none but uses training leaf counts.

Pitfalls

Comparing SHAP values computed with different backgrounds across model versions.

Lessons and concepts

Claims and their sources

  • TreeExplainer's interventional mode requires a background dataset (100 to 1000 random samples suggested); tree_path_dependent uses per-leaf training counts as the background; SHAP values plus expected_value equal the model output in the chosen output space.

    shap.TreeExplainer (SHAP API reference)