preprocess_data: Process (check and update) data according to specified...

Description Usage Arguments Details Value Author(s) Examples

View source: R/preprocess_data.R

Description

Process (check and update) data according to specified feature list

Usage

1
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.

feature_list

List. Output from running get_data_specs or get_model_specs

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# 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)
}

shapr documentation built on Jan. 28, 2021, 5:06 p.m.