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

View source: R/preprocess_data.R

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

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

# 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 May 4, 2023, 5:10 p.m.