plot_image_explanation function

Display image explanations as superpixel areas

Display image explanations as superpixel areas

When classifying images one is often interested in seeing the areas that supports and/or contradicts a classification. plot_image_explanation() will take the result of an image explanation and highlight the areas found relevant to each label in the explanation. The highlighting can either be done by blocking the parts of the image not related to the classification, or by encircling and colouring the areas that influence the explanation.

plot_image_explanation( explanation, which = 1, threshold = 0.02, show_negative = FALSE, display = "outline", fill_alpha = 0.3, outline_col = c("blue", "red"), block_col = "grey" )

Arguments

  • explanation: The explanation created with an image_explainer

  • which: The case in explanation to illustrate. plot_image_explanation

    only supports showing one case at a time.

  • threshold: The lowest absolute weighted superpixels to include

  • show_negative: Should areas that contradicts the prediction also be shown

  • display: How should the areas be shown? Either outline or block

  • fill_alpha: In case of display = 'outline' how opaque should the area colour be?

  • outline_col: A vector of length 2 giving the colour for supporting and contradicting areas respectively if display = 'outline'

  • block_col: The colour to use for the unimportant areas if display = 'block'

Returns

A ggplot object

Examples

## Not run: # load precalculated explanation as it takes a long time to create explanation <- .load_image_example() # Default plot_image_explanation(explanation) # Block out background instead plot_image_explanation(explanation, display = 'block') # Show negatively correlated areas as well plot_image_explanation(explanation, show_negative = TRUE) ## End(Not run)
  • Maintainer: Emil Hvitfeldt
  • License: MIT + file LICENSE
  • Last published: 2022-08-19