View source: R/preprocess_data.R
preprocess_data | R Documentation |
Process (check and update) data according to specified feature list
preprocess_data(x, feature_list)
x |
matrix, data.frame or data.table. The data to check input for and update
according to the specification in |
feature_list |
List. Output from running |
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
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
Martin Jullum
# 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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.