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.
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 createexplanation <- .load_image_example()# Defaultplot_image_explanation(explanation)# Block out background insteadplot_image_explanation(explanation, display ='block')# Show negatively correlated areas as wellplot_image_explanation(explanation, show_negative =TRUE)## End(Not run)