
Last chance! 50% off unlimited learning
Sale ends in
Fetches feature labels from a given model object
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)
Model object for the model to be explained.
Character vector. Represents the names of the columns in the data used for training/explaining.
Character vector. Represents the labels of the features used for prediction.
# NOT RUN {
if (requireNamespace("MASS", quietly = TRUE)) {
# 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