preprocess_data {shapr} | R Documentation |
Process (check and update) data according to specified feature list
Description
Process (check and update) data according to specified feature list
Usage
preprocess_data(x, feature_list)
Arguments
x |
matrix, data.frame or data.table. The data to check input for and update
according to the specification in |
feature_list |
List. Output from running |
Details
This function takes care of all preprocessing and checking of the provided data in x
against
the feature_list which is typically the output from get_model_specs
Value
List with two named elements: x_dt
: Checked and updated data x
in data.table format, and
update_feature_list
the output from check_features
Author(s)
Martin Jullum
Examples
# Load example data
if (requireNamespace("MASS", quietly = TRUE)) {
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)]
data_features <- get_data_specs(x_train)
model <- lm(medv ~ lstat + rm + rad + indus, data = x_train)
model_features <- get_model_specs(model)
preprocess_data(x_train, model_features)
}
[Package shapr version 0.2.2 Index]