Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Discrepancy among SHAP beeswarm and Seaborn swarmplots #3496

Open
3 of 4 tasks
ggmirandac opened this issue Feb 10, 2024 · 0 comments
Open
3 of 4 tasks

BUG: Discrepancy among SHAP beeswarm and Seaborn swarmplots #3496

ggmirandac opened this issue Feb 10, 2024 · 0 comments
Labels
bug Indicates an unexpected problem or unintended behaviour visualization Relating to plotting

Comments

@ggmirandac
Copy link

Issue Description

I am using seaborn to plot the shap values and showing their relation with the data that was used for the prediction to avoid plotting nan values and I notice some differents between the plots. When I am compare both plots I notice that the the shap's api plot overstimates the value of the data.

Comparison:
SHAP plot:
8faf3441-dcb3-4aba-b9b2-886ec27df724

Seaborn plot:
cfdaccbe-eb0f-4c7a-a30d-606267a659bd

Just to inform, I am using the color map 'bwr' of matplotlib to compare.

Minimal Reproducible Example

import shap
# explain is the Explanation object
dic ={
    'feature_name':'ER',
    'shap_values':explain.values[:,0],
    'data': explain.data[:,0]
}
# for the seaborn
sns.swarmplot(x = 'shap_values', y = 'feature_name',hue = 'data', data = dic, palette='bwr', size = 3)

# for the shap
fig = plt.figure(figsize=(12, 5), dpi = 600)
shap.plots.beeswarm(explain[:,['ER']], show=False, max_display=len(explain.feature_names), plot_size=(6,10),
                    color_bar_label = '-',  color_bar=True, color = 'bwr')

Traceback

No response

Expected Behavior

There should be a correspondence between the values of the data in the plots. The color maps should show similar color behavior

Bug report checklist

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest release of shap.
  • I have confirmed this bug exists on the master branch of shap.
  • I'd be interested in making a PR to fix this bug

Installed Versions

version: 0.44.0

@ggmirandac ggmirandac added the bug Indicates an unexpected problem or unintended behaviour label Feb 10, 2024
@connortann connortann added the visualization Relating to plotting label Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behaviour visualization Relating to plotting
Projects
None yet
Development

No branches or pull requests

2 participants