ModelOriented/shapviz

Multiclass/Multioutput/multiple models

mayer79 opened this issue · 1 comments

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

  • multiple models,
  • a multi-class model (XGBoost, kernelshap), or
  • a multi-output regression (kernelshap).

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.

Implemented in #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