Learn R Programming

shapviz (version 0.9.7)

extractors: Extractor Functions

Description

Functions to extract SHAP values, feature values, the baseline, or SHAP interactions from a "(m)shapviz" object.

Usage

get_shap_values(object, ...)

# S3 method for shapviz get_shap_values(object, ...)

# S3 method for mshapviz get_shap_values(object, ...)

# S3 method for default get_shap_values(object, ...)

get_feature_values(object, ...)

# S3 method for shapviz get_feature_values(object, ...)

# S3 method for mshapviz get_feature_values(object, ...)

# S3 method for default get_feature_values(object, ...)

get_baseline(object, ...)

# S3 method for shapviz get_baseline(object, ...)

# S3 method for mshapviz get_baseline(object, ...)

# S3 method for default get_baseline(object, ...)

get_shap_interactions(object, ...)

# S3 method for shapviz get_shap_interactions(object, ...)

# S3 method for mshapviz get_shap_interactions(object, ...)

# S3 method for default get_shap_interactions(object, ...)

Value

  • get_shap_values() returns the matrix of SHAP values,

  • get_feature_values() the data.frame of feature values,

  • get_baseline() the numeric baseline value, and

  • get_shap_interactions() the SHAP interactions of the input.

For objects of class "mshapviz", these functions return lists of those elements.

Arguments

object

Object to extract something.

...

Currently unused.

Examples

Run this code
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))
shp <- shapviz(S, X, baseline = 4)
get_shap_values(shp)

Run the code above in your browser using DataLab