An empirical study of the effect of background data size on the stability of SHapley Additive exPlanations (SHAP) for deep learning models

Han Yuan, Mingxuan Liu, Lican Kang, Chenkui Miao, Ying Wu

TL;DR

SHAP explanations for deep learning models are surprisingly sensitive to the size of the "background dataset" used to calculate them. This study reveals that while small background sets lead to unstable feature rankings, increasing the sample size significantly improves reliability—particularly for the most and least important variables.

What Problem Does This Paper Address?

Deep learning models are notoriously "black boxes," making tools like SHapley Additive exPlanations (SHAP) essential for understanding why a model makes a specific prediction. To interpret deep learning models, SHAP’s DeepExplainer requires a "background dataset" to serve as a reference point for feature contributions.

While the official SHAP documentation suggests that 100 randomly sampled instances are sufficient, other researchers often use vastly different sizes. This paper investigates whether this choice actually matters. If the explanation changes every time you pick a different set of 100 background samples, can we really trust the "interpretation" the tool provides?

Methods

The authors conducted an empirical study using an Artificial Neural Network (ANN) trained on clinical data. They varied the background dataset size from 100 to 1,000 samples and ran 100 simulations for each size to measure "fluctuation"—how much the explanations changed across different random samples.

To quantify this instability, they introduced two clever metrics borrowed from other fields:

  • Quartile-based BLEU Score: Originally used in machine translation to compare word order, here it measures how much the exact order of feature rankings changes.
  • Quartile-based Jaccard Index: A measure of set similarity used to see if the same groups of variables (e.g., the top 25% most important) remain consistent, even if their internal order shifts.

Datasets

The study utilized the MIMIC-III (Medical Information Mart for Intensive Care) dataset, a large, de-identified collection of ICU patient data. They focused on 44,918 admission episodes to predict patient mortality based on 17 clinical variables, including heart rate, age, glucose levels, and blood pressure.

Key Insights and Ideas

  • The Stability Gap: One-shot SHAP explanations can be fickle. With small background datasets, the "most important" feature in one run might drop significantly in another simply due to sampling noise.
  • The U-Shape Phenomenon: The authors discovered a "U-shape" in stability. SHAP is very reliable at identifying the most important and the least important variables. However, it struggles with "moderately important" variables, which tend to swap places frequently.
  • Group vs. Order: Interestingly, the Jaccard index was high (above 0.86) even for small sample sizes. This suggests that while SHAP is good at identifying the general pool of important features, it needs more data to get their exact ranking right.
  • Linear Complexity: There is a direct linear relationship between background size and computational cost. Doubling your background data doubles your calculation time, creating a clear trade-off between speed and certainty.

Key Results

The results clearly show that "bigger is better" for explanation stability:

  • Variance Reduction: The statistical variance of SHAP values dropped sharply as the background size increased. For example, the variance for "Age" dropped from 153.31 (at size 100) to 11.21 (at size 1,000).
  • Ranking Consistency: The average BLEU score (measuring exact ranking stability) improved from 0.432 to 0.644 as the sample size increased to 1,000.
  • Visual Evidence: As seen in the comparison below, the variable rankings become much more consistent (indicated by solid vertical color blocks) when the background size is increased.
Figure 1: Fluctuation of variable rankings using background sizes of 100 and 1,000. Based on 100 simulations, we obtained 100 variable rankings for each of the two background sizes. Each row corresponds to one simulation; each column represents a variable’s ranking order across the 100 simulations. The color bar on the right indicates the variable ranking sequence (blue means low rankings and yellow stands for high rankings). The small color blocks in each column of sub-figure (b) change less than these of (a), indicating smaller volatilities.

Limitations and Future Work

The authors acknowledge several limitations:

  1. Scope: The study was limited to a single dataset (MIMIC-III) and one specific type of deep learning model (a 3-layer ANN).
  2. Simulation Scale: They performed 100 simulations per scenario; larger-scale simulations might provide even more granular insights.
  3. The "Optimal" Number: While the study proves that 1,000 is better than 100, it doesn't define a formal "optimal" size, which likely depends on the specific model and dataset complexity.

Future work could involve testing these stability measures across different architectures (like CNNs or Transformers) and exploring more sophisticated sampling methods beyond simple random selection.

Summary updated

BibTeX
@misc{yuan2022empirical,
  author = {Han Yuan and Mingxuan Liu and Lican Kang and Chenkui Miao and Ying Wu},
  title = {{An empirical study of the effect of background data size on the stability of SHapley Additive exPlanations (SHAP) for deep learning models}},
  year = {2022},
  eprint = {2204.11351},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2204.11351},
}
Figure