MrShapely: Generate SHAP (SHapley Additive exPlanations) Plots for...

View source: R/MrShapely.R

MrShapelyR Documentation

Generate SHAP (SHapley Additive exPlanations) Plots for Multiple Models and Responses

Description

This function generates SHAP (SHapley Additive exPlanations) plots for multiple models and responses.

Usage

MrShapely(
  yhats,
  MultRespVars = Resp,
  taxa = NULL,
  kind = "beeswarm",
  max_display = 15L,
  color_var = NULL,
  getFeaturePlot = TRUE,
  getDependencyPlot = TRUE,
  get2DDependencyPlot = TRUE,
  num_cores = 2,
  class_selection = NULL
)

Arguments

yhats

A list of model prediction objects. Each object should contain a model, data, and class information.

MultRespVars

A data frame containing response variables for the prediction.

taxa

An optional vector specifying which responses to include based on their indices.

kind

A character string specifying the type of plots (e.g., "beeswarm" for feature effect plot, "bar" for variable importance plot, or "both").

max_display

An integer specifying the maximum number of features to display.

color_var

A variable to use for coloring in the dependency plots.

getFeaturePlot

A logical indicating whether to generate feature effect plots.

getDependencyPlot

A logical indicating whether to generate dependency plots.

num_cores

An integer specifying the number of CPU cores to use for parallel processing.

class_selection

An optional vector specifying which classes to include in the plots.

x_features

A character vector specifying the features to consider in the plots.

y_features

A character vector specifying the response features for interaction plots.

interactions

A logical indicating whether to create interaction effect plots.

getInteractionPlot

A logical indicating whether to generate interaction plots.

Value

A ggplot object containing SHAP plots for the specified responses and features. Note that this function may not work for some algorithm classe (e.g., neural nets)

Examples

# Example usage:
MrShapely(yhats, MultRespVars = Resp)

nfj1380/mrIML documentation built on May 17, 2024, 7:41 a.m.