Use standard square bracket subsetting to select rows and/or columns of SHAP values, feature values, and SHAP interaction values of a "shapviz" object.

# S3 method for class 'shapviz'
x[i, j, ...]

Arguments

x

An object of class "shapviz".

i

Row subsetting.

j

Column subsetting.

...

Currently unused.

Value

A new object of class "shapviz".

See also

Examples

S <- matrix(c(1, -1, -1, 1), ncol = 2, dimnames = list(NULL, c("x", "y")))
X <- data.frame(x = c("a", "b"), y = c(100, 10))
x <- shapviz(S, X, baseline = 4)
x[1, "x"]
#> 'shapviz' object representing 1 x 1 SHAP matrix. Top lines:
#> 
#>      x
#> [1,] 1
x[1]
#> 'shapviz' object representing 1 x 2 SHAP matrix. Top lines:
#> 
#>      x  y
#> [1,] 1 -1
x[c(FALSE, TRUE), ]
#> 'shapviz' object representing 1 x 2 SHAP matrix. Top lines:
#> 
#>       x y
#> [1,] -1 1
x[, "x"]
#> 'shapviz' object representing 2 x 1 SHAP matrix. Top lines:
#> 
#>       x
#> [1,]  1
#> [2,] -1