Learn R Programming

shapr (version 0.1.3)

features: Fetches feature labels from a given model object

Description

Fetches feature labels from a given model object

Usage

features(x, cnms, feature_labels = NULL)

# S3 method for default features(x, cnms, feature_labels = NULL)

# S3 method for lm features(x, cnms, feature_labels = NULL)

# S3 method for glm features(x, cnms, feature_labels = NULL)

# S3 method for ranger features(x, cnms, feature_labels = NULL)

# S3 method for gam features(x, cnms, feature_labels = NULL)

# S3 method for xgb.Booster features(x, cnms, feature_labels = NULL)

Arguments

x

Model object for the model to be explained.

cnms

Character vector. Represents the names of the columns in the data used for training/explaining.

feature_labels

Character vector. Represents the labels of the features used for prediction.

Examples

Run this code
# NOT RUN {
# Load example data
data("Boston", package = "MASS")
# Split data into test- and training data
x_train <- head(Boston, -3)
# Fit a linear model
model <- lm(medv ~ lstat + rm + dis + indus, data = x_train)

cnms <- c("lstat", "rm", "dis", "indus")

# Checking that features used by the model corresponds to cnms
features(x = model, cnms = cnms, feature_labels = NULL)
# }

Run the code above in your browser using DataLab