shap.plots.image
- shap.plots.image(shap_values: ~shap._explanation.Explanation, pixel_values: ~numpy.ndarray | None = None, labels: list | None = None, true_labels: list | None = None, width: int | None = 20, aspect: float | None = 0.2, hspace: float | None = 0.2, labelpad: float | None = None, cmap: str | None = <matplotlib.colors.LinearSegmentedColormap object>, show: bool | None = True)
Plots SHAP values for image inputs.
- Parameters:
- shap_values[numpy.array]
List of arrays of SHAP values. Each array has the shape (# samples x width x height x channels), and the length of the list is equal to the number of model outputs that are being explained.
- pixel_valuesnumpy.array
Matrix of pixel values (# samples x width x height x channels) for each image. It should be the same shape as each array in the
shap_values
list of arrays.- labelslist or np.ndarray
List or
np.ndarray
(# samples x top_k classes) of names for each of the model outputs that are being explained.- true_labels: list
List of a true image labels to plot.
- widthfloat
The width of the produced matplotlib plot.
- labelpadfloat
How much padding to use around the model output labels.
- showbool
Whether
matplotlib.pyplot.show()
is called before returning. Setting this toFalse
allows the plot to be customized further after it has been created.
Examples
See image plot examples.