plot.shapley {ShapleyOutlier} | R Documentation |
Barplot of Shapley values
Description
Barplot of Shapley values
Usage
## S3 method for class 'shapley'
plot(
x,
subset = NULL,
chi2.q = 0.99,
abbrev.var = 3,
abbrev.obs = 10,
sort.var = FALSE,
sort.obs = FALSE,
plot_md = TRUE,
md_squared = TRUE,
rotate_x = TRUE,
...
)
Arguments
x |
A list of class |
subset |
Either an integer, |
chi2.q |
Quantile, only used if |
abbrev.var |
Integer. If |
abbrev.obs |
Integer. If |
sort.var |
Logical. If |
sort.obs |
Logical. If |
plot_md |
Logical. If |
md_squared |
Logical. If |
rotate_x |
Logical. If |
... |
Optional arguments passed to methods. |
Value
Returns a barplot that displays the Shapley values (shapley
)for each observation and optionally (plot_md = TRUE
)
includes the squared Mahalanobis distance (black bar) and the corresponding (non-)central chi-square quantile (dotted line).
Examples
library(MASS)
set.seed(1)
n <- 100; p <- 10
mu <- rep(0,p)
Sigma <- matrix(0.9, p, p); diag(Sigma) = 1
X <- mvrnorm(n, mu, Sigma)
X_clean <- X
X[sample(1:(n*p), 100, FALSE)] <- rep(c(-5,5),50)
call_shapley <- shapley(X, mu, Sigma)
plot(call_shapley, subset = 1:20)
plot(call_shapley, subset = 5, rotate_x = FALSE)
plot(call_shapley, subset = 5, md_squared = FALSE, rotate_x = FALSE)