check_features: Checks that two extracted feature lists have exactly the same...

Description Usage Arguments Value Author(s) Examples

View source: R/preprocess_data.R

Description

Checks that two extracted feature lists have exactly the same properties

Usage

1
check_features(f_list_1, f_list_2, use_1_as_truth = T)

Arguments

f_list_1, f_list_2

List. As extracted from either get_data_specs or get_model_specs.

use_1_as_truth

Logical. If TRUE, f_list_2 is compared to f_list_1, i.e. additional elements is allowed in f_list_2, and if f_list_1's feature classes contains NAs, feature class check is ignored regardless of what is specified in f_list_1. If FALSE, f_list_1 and f_list_2 are equated and they need to contain exactly the same elements. Set to TRUE when comparing a model and data, and FALSE when comparing two data sets.

Value

List. The f_list_1 is returned as inserted if there all check are carried out. If some info is missing from f_list_1, the function continues consistency checking using f_list_2 and returns that.

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

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