plot_shap_beeswarm function

SHAP importance beeswarm plot

SHAP importance beeswarm plot

plot_shap_beeswarm( shap, x, cex = 0.25, corral = "random", corral.width = 0.7, scheme = c("deepskyblue2", "purple3", "red"), sort = TRUE, top = NULL, ... )

Arguments

  • shap: a matrix of SHAP values
  • x: a matrix or dataframe of feature values containing only features values from the training data. The rows must match rows in shap. If a dataframe is supplied it is converted to a numeric matrix using data.matrix().
  • cex: Scaling for adjusting point spacing. See ggbeeswarm::geom_beeswarm().
  • corral: String specifying method used to corral points. See ggbeeswarm::geom_beeswarm().
  • corral.width: Numeric specifying width of corral, passed to geom_beeswarm
  • scheme: Colour scheme as a vector of 3 colours
  • sort: Logical whether to sort predictors by mean absolute SHAP value.
  • top: Sets a limit on the number of variables plotted or NULL to plot all variables. If top is set then variables are sorted and sort is overrode.
  • ...: Other arguments passed to ggbeeswarm::geom_beeswarm() e.g. size.

Returns

A ggplot2 plot

  • Maintainer: Myles Lewis
  • License: MIT + file LICENSE
  • Last published: 2025-03-10