SHAP

Creator
Creator
Seonglae Cho
Created
Created
2024 Apr 6 13:28
Editor
Edited
Edited
2025 Mar 25 1:42
Refs
Refs
LIME

Shapley Additive exPlanations, Shapley Values

A classical method for interpreting AI that quantifies how much each feature contributes to a prediction
  • The goal of SHAP is to explain the prediction of an instance x by computing the contribution of each feature to the prediction
  • Build around idea of
    Shapley values
    (assume feature is a player and combination as colition)
notion image
pip install shap
notion image
import shap explainer = shap.Explainer(classifier) shap_values = explainer(counterfactuals) shap_values_stereotype = shap_values[:, :, "stereotype"].values shap_vectors = [] # Save SHAP values in vectors for subsequent calculation for index, values in enumerate(shap_values_stereotype): # Trim to exclude whitespace and punctuation trimmed_values = values[1:-2] shap_vectors.append(trimmed_values) print(f"Sentence {index+1} SHAP vector: {trimmed_values}") shap.plots.text(shap_values[:, :, "stereotype"])
 

SHAP variants

  • KernelSHAP
  • TreeSHA

SHAP interpretation methods

  • SHAP Feature Importance
  • SHAP Summary Plot
  • SHAP Dependence Plot
  • SHAP Interaction Values
 
 
 
 
 
 

Recommendations