Learn R Programming

bartXViz (version 1.0.8)

plot.Explain: A Function for Visualizing the Shapley Values

Description

The plot.Explain function provides various visualization methods for Shapley values. The values and format used in the graph are determined based on the input parameters.

Usage

# S3 method for Explain
plot(
  x,
  average = NULL,
  type = NULL,
  num_post = NULL,
  plot.flag = TRUE,
  adjust = FALSE,
  probs = 0.95,
  title = NULL,
  ...
)

Value

The plot is returned based on the specified option.:

out

If average is "obs" or "post", a bar plot or summary plot is generated based on the selected averaging criterion. If average is "both", a boxplot is displayed to show the distribution of Shapley values computed using both criteria. If adjust is TRUE, the adjusted Shapley values are displayed. If num_post is specified, a bar plot or summary plot for the selected posterior sample is generated.

Arguments

x

An Explain class object containing the Shapley values of models.

average

Input the reference value for calculating the mean of the object's phi list. "obs" represents the average based on observations (#post by #variable), while "post" represents the average based on posterior samples (#obs by #variable). If "both" is entered, calculations are performed based on both observation and posterior sample criteria. If no value is specified, "both" is used as the default.

type

"bar" represents a bar chart that includes the average contribution of each variable, while "bee" represents a summary plot, allowing you to determine the graph's format.

num_post

To check the contribution of variables for a single posterior sample, enter a value within the number of posterior samples.

plot.flag

If average = "obs", the quantile interval of each variable's is provided by default.

adjust

The default value is FALSE. Enter TRUE to check the Shapley values adjusted based on the model's average contribution.

probs

Enter the probability for the quantile interval. The default value is 0.95.

title

The title of the plot, with a default value of NULL.

...

Additional arguments to be passed