Questions tagged [shap]

SHAP (SHapley Additive exPlanations) is a unified approach to explain the output of any machine learning model. SHAP connects game theory with local explanations, uniting several previous methods and representing the only possible consistent and locally accurate additive feature attribution method based on expectations (see the SHAP NIPS paper for details).

453 questions
12
votes
1 answer

Does SHAP in Python support Keras or TensorFlow models while using DeepExplainer?

I am currently using SHAP Package to determine the feature contributions. I have used the approach for XGBoost and RandomForest and it worked really well. Since the data I am working on is a sequential data I tried using LSTM and CNN to train the…
Yash Sharma
  • 142
  • 1
  • 8
11
votes
5 answers

Shap - The color bar is not displayed in the summary plot

When displaying summary_plot, the color bar does not show. shap.summary_plot(shap_values, X_train) I have tried changing plot_size. When the plot is higher the color bar appears, but it is very small - doesn't look like it…
nietoperz21
  • 303
  • 3
  • 12
11
votes
2 answers

Difference between Shapley values and SHAP for interpretable machine learning

The Paper regarding die shap package gives a formula for the Shapley Values in (4) and for SHAP values apparently in (8) Still I don't really understand the difference between Shapley and SHAP values. As far as I understand for Shapley I need to…
Quastiat
  • 1,164
  • 1
  • 18
  • 37
9
votes
2 answers

PyTorch Error loading "\lib\site-packages\torch\lib\shm.dll" or one of its dependencies

I cannot use PyTorch and Shap getting this error PyTorch Error loading "\lib\site-packages\torch\lib\shm.dll" or one of its dependencies. I have tried to uninstall and re-install PyTorch, failed create a new conda environment and reinstalled…
fede72bari
  • 343
  • 5
  • 17
9
votes
1 answer

SHAP function throws exception in plotting method

samples.zip The sample zipped folder contains: model.pkl x_test.csv To reproduce the problems, do the following steps: use lin2 =joblib.load('model.pkl') to load the linear regression model use x_test_2 = pd.read_csv('x_test.csv').drop(['Unnamed:…
user2150279
  • 445
  • 2
  • 8
  • 17
9
votes
1 answer

What do maskers really do in SHAP package and fit them to train or test?

I have been trying to work with the shap package. I want to determine the shap values from my logistic regression model. Contrary to the TreeExplainer, the LinearExplainer requires a so-called masker. What exactly does this masker do and what is the…
JonnDough
  • 827
  • 6
  • 25
9
votes
1 answer

How to use SHAP with a linear SVC model from sklearn using Pipeline?

I am doing text classification using a linear SVC model from sklearn. Now I want to visualize which words/tokens have the highest impact on the classification decision by using SHAP (https://github.com/slundberg/shap). Right now this does not work…
translater
  • 101
  • 1
  • 5
8
votes
2 answers

I get an error when using shap.plots.waterfall after generating the shap values

For the code given below, if I just use the command shap.plots.waterfall(shap_values[6]) I get the error 'numpy.ndarray' object has no attribute 'base_values' I have to firstly run these two commands: explainer2 =…
Joe
  • 357
  • 2
  • 10
  • 32
8
votes
1 answer

Create SHAP plots for tidymodel objects

This question refers to Obtaining summary shap plot for catboost model with tidymodels in R. Given the comment below the question, the OP found a solution but did not share it with the community so far. I want to analyze my tree ensembles fitted…
mugdi
  • 365
  • 5
  • 17
8
votes
1 answer

Feature importance in a binary classification and extracting SHAP values for one of the classes only

Suppose we have a binary classification problem, we have two classes of 1s and 0s as our target. I aim to use a tree classifier to predict 1s and 0s given the features. Further, I can use SHAP values to rank the feature importance that are…
Wiliam
  • 1,078
  • 10
  • 21
7
votes
2 answers

How to get SHAP values for Huggingface Transformer Model Prediction [Zero-Shot Classification]?

Given a Zero-Shot Classification Task via Huggingface as follows: from transformers import pipeline classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli") example_text = "This is an example text about snowflakes in the…
Pete
  • 100
  • 4
  • 15
7
votes
2 answers

Why are shap values changing every time I call shap.plots.beeswarm?

So here's my code using shap : Since I just plot three times the same shape values, I'd expect the three plots to be the same. However, it keeps on changing. After some research, it seems that a new value appear at the top at each call, but why ?…
SashimiDélicieux
  • 476
  • 1
  • 5
  • 17
7
votes
1 answer

SHAP DeepExplainer with TensorFlow 2.4+ error

I'm trying to compute shap values using DeepExplainer, but I get the following error: keras is no longer supported, please use tf.keras instead Even though i'm using tf.keras? KeyError Traceback (most recent call last) in 6 # ...or pass…
Fred
  • 85
  • 1
  • 5
7
votes
3 answers

Python Jupyter notebook SHAP force_plot, how to change the background color or text color in the dark theme?

Is there any way that I can change the shap plot background color or text color in the dark theme? I need either the white background or white text. The plot is an object of IPython.core.display.HTML. It is generated…
J.D
  • 1,885
  • 4
  • 11
  • 19
7
votes
1 answer

How to save a plot (generated by shap_values) to png?

I use Shap library to visualize variable importance. I try to save shap_summary_plot as 'png' image but my image.png but them get an empty image this is the code that I have used: shap_values =…
Maite89
  • 273
  • 2
  • 8
1
2 3
30 31