plot.shapley_algorithm {ShapleyOutlier} | R Documentation |
Barplot and tileplot of Shapley values.
Description
Barplot and tileplot of Shapley values.
Usage
## S3 method for class 'shapley_algorithm'
plot(
x,
type = "both",
subset = NULL,
abbrev.var = FALSE,
abbrev.obs = FALSE,
sort.var = FALSE,
sort.obs = FALSE,
n_digits = 2,
rotate_x = TRUE,
continuous_rowname = FALSE,
...
)
Arguments
x |
A list of class |
type |
Either |
subset |
Either an integer, |
abbrev.var |
Integer. If |
abbrev.obs |
Integer. If |
sort.var |
Logical. If |
sort.obs |
Logical. If |
n_digits |
Integer. If |
rotate_x |
Logical. If |
continuous_rowname |
Logical. If |
... |
Arguments passed on to |
Value
Returns plots for a list of class shapley_algorithm
.
If type
is "bar"
, a barplot is generated. It 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).
If type
is "cell"
a tileplot is generated. It displays each cells of the dataset and shows the original value from the observations,
color coding indicates whether those values were higher (red) or lower (blue) than the imputed values,
and the color intensity is based on the magnitude of the Shapley value.
If type
is "both"
, the barplot and the tileplot are generated.
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[sample(1:(n*p), 100, FALSE)] <- rep(c(-5,5),50)
MOE_X <- MOE(X, mu, Sigma)
plot(MOE_X, subset = 20, n_digits = 0)