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: image_plot Original image NOT showing #3375

Open
4 tasks done
snkrbhr opened this issue Oct 31, 2023 · 2 comments
Open
4 tasks done

BUG: image_plot Original image NOT showing #3375

snkrbhr opened this issue Oct 31, 2023 · 2 comments
Labels
bug Indicates an unexpected problem or unintended behaviour visualization Relating to plotting

Comments

@snkrbhr
Copy link

snkrbhr commented Oct 31, 2023

Issue Description

I simply follow this example from the official website Explain ResNet50 ImageNet classification using Partition explainer but the output image is partial.

Example: https://shap.readthedocs.io/en/latest/example_notebooks/image_examples/image_classification/Image%20Multi%20Class.html

When using the shap.image_plot(shap_value) function to visualize SHAP (SHapley Additive exPlanations) values for an original image, the original images are not displayed as expected. The shap_value parameter represents the SHAP values associated with the image, and the function is designed to display the original image alongside its SHAP values. However, in the current implementation, the original image is not appearing in the generated plot.

image

This issue persist in Jupyter notebook, Colab and even I tried Chrom and Firefox browser

Minimal Reproducible Example

shap.image_plot(shap_value)

Follow this Example: https://shap.readthedocs.io/en/latest/example_notebooks/image_examples/image_classification/Image%20Multi%20Class.html

Traceback

No response

Expected Behavior

The shap.image_plot function is expected to display the original image along with the SHAP values to provide a comprehensive visualization of feature attributions. This helps users understand the impact of each feature on the model's output.

image

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

0.43.0

@snkrbhr snkrbhr added the bug Indicates an unexpected problem or unintended behaviour label Oct 31, 2023
@igraugar
Copy link

igraugar commented Nov 8, 2023

I have the same problem, following.

@connortann connortann added the visualization Relating to plotting label Nov 29, 2023
@caminada87
Copy link

Try to transform the original image in the second argument of image_plot: "pixel_values (numpy.array)" like this (i just use one image here so [0:1]):

shap.image_plot(shap_values, X[0:1]/255)

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

4 participants