ModelOriented / shapviz

SHAP Plots in R
https://modeloriented.github.io/shapviz/
GNU General Public License v2.0
78 stars 13 forks source link

Multiclass/Multioutput/multiple models #73

Closed mayer79 closed 1 year ago

mayer79 commented 1 year ago

Introduce class "mshapviz" that would combine multiple "shapviz" objects representing SHAP values from

Multiple "shapviz" objects could be combined to a "mshapviz" object by c(...) or mshapviz(...). Existing methods like [, +, rbind, colnames, dim would need to be written to cover "mshapviz" objects as well.

As a start, the sv_xyz() plot functions would use patchwork::wrap_plots(list). The resulting combined plot can be modified using &, e.g., & ylim(...). This gives quite some flexibility.

mayer79 commented 1 year ago

Implemented in https://github.com/ModelOriented/shapviz/pull/74

Example from new vignette:

library(ggplot2)
library(shapviz)
library(patchwork)
library(ranger)
library(kernelshap)

fit <- ranger(Species ~ ., data = iris, num.trees = 100L, probability = TRUE)
x <- kernelshap(fit, X = iris, bg_X = iris)
shp <- setNames(shapviz(x), levels(iris$Species))

sv_dependence(shp, v = "Sepal.Width") +
  plot_layout(ncol = 1L) &
  ylim(-0.025, 0.03)

VIGNETTE-dep-ranger