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

Description Usage Arguments Value Author(s) Examples

View source: R/preprocess_data.R

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

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# 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 Jan. 28, 2021, 5:06 p.m.