get_model_specs | R Documentation |
Fetches feature information from a given model object
get_model_specs(x)
## Default S3 method:
get_model_specs(x)
## S3 method for class 'lm'
get_model_specs(x)
## S3 method for class 'glm'
get_model_specs(x)
## S3 method for class 'gam'
get_model_specs(x)
## S3 method for class 'ranger'
get_model_specs(x)
## S3 method for class 'xgb.Booster'
get_model_specs(x)
x |
Model object for the model to be explained. |
This function is used to extract the feature information to be checked against data passed to shapr
and explain
. The function is called from preprocess_data
.
A list with the following elements:
character vector with the feature names to compute Shapley values for
a named character vector with the labels as names and the class type as elements
a named list with the labels as names and character vectors with the factor levels as elements (NULL if the feature is not a factor)
Martin Jullum
if (requireNamespace("MASS", quietly = TRUE)) {
# Load example data
data("Boston", package = "MASS")
# Split data into test- and training data
x_train <- data.table::as.data.table(head(Boston))
x_train[, rad := as.factor(rad)]
model <- lm(medv ~ lstat + rm + rad + indus, data = x_train)
get_model_specs(model)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.