update_data: Updates data by reference according to the updater argument.

View source: R/preprocess_data.R

update_dataR Documentation

Updates data by reference according to the updater argument.

Description

data is updated, i.e. unused columns and factor levels are removed as described in updater. This is done by reference, i.e. updates the object being passed to data even if nothing is returned by the function itself.

Usage

update_data(data, updater)

Arguments

data

data.table. Data that ought to be updated.

updater

List. The object should be the output from check_features.

Value

NULL.

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)
  updater <- check_features(model_features, data_features)
  update_data(x_train, updater)
}

shapr documentation built on May 4, 2023, 5:10 p.m.