shap.plots.text

shap.plots.text(shap_values, num_starting_labels=0, group_threshold=1, separator='', xmin=None, xmax=None, cmax=None)

Plots an explanation of a string of text using coloring and interactive labels.

The output is interactive HTML and you can click on any token to toggle the display of the SHAP value assigned to that token.

Parameters
shap_values[numpy.array]

List of arrays of SHAP values. Each array has the shap values for a string(# input_tokens x output_tokens).

num_starting_labelsint

Number of tokens (sorted in decending order by corresponding SHAP values) that are uncovered in the initial view. When set to 0 all tokens covered.

group_thresholdfloat

The threshold used to group tokens based on interaction affects of SHAP values.

separatorstring

The string seperator that joins tokens grouped by interation effects and unbroken string spans.

xminfloat

Minimum shap value bound.

xmaxfloat

Maximum shap value bound.

cmaxfloat

Maximum absolute shap value for sample. Used for scaling colors for input tokens.