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.

base_valuefloat or shap.Explanation

If a float is passed in, this is the reference value that the feature contributions start from. For SHAP values, it should be the value of explainer.expected_value. However, it is recommended to pass in a SHAP Explanation object instead (shap_values is not necessary in this case).


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.


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.


List of feature names (# features).


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.

plot_cmapstr or list[str]

Color map to use. It can be a string (defaults to RdBu) or a list of hex color strings.


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. Defaults to False.


Whether is called before returning. Setting this to False allows the plot to be customized further after it has been created. Only applicable when matplotlib is set to True.


Figure size of the matplotlib output.


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.