shap.plots.force

shap.plots.force(base_value, shap_values=None, features=None, feature_names=None, out_names=None, link='identity', plot_cmap='RdBu', matplotlib=False, show=True, figsize=(20, 3), ordering_keys=None, ordering_keys_time_format=None, text_rotation=0, contribution_threshold=0.05)

Visualize the given SHAP values with an additive force layout.

Parameters
base_valuefloat

This is the reference value that the feature contributions start from. For SHAP values it should be the value of explainer.expected_value.

shap_valuesnumpy.array

Matrix of SHAP values (# features) or (# samples x # features). If this is a 1D array then a single force plot will be drawn, if it is a 2D array then a stacked force plot will be drawn.

featuresnumpy.array

Matrix of feature values (# features) or (# samples x # features). This provides the values of all the features, and should be the same shape as the shap_values argument.

feature_nameslist

List of feature names (# features).

out_namesstr

The name of the output of the model (plural to support multi-output plotting in the future).

link“identity” or “logit”

The transformation used when drawing the tick mark labels. Using logit will change log-odds numbers into probabilities.

matplotlibbool

Whether to use the default Javascript output, or the (less developed) matplotlib output. Using matplotlib can be helpful in scenarios where rendering Javascript/HTML is inconvenient.

contribution_thresholdfloat

Controls the feature names/values that are displayed on force plot. Only features that the magnitude of their shap value is larger than min_perc * (sum of all abs shap values) will be displayed.