| apply_preprocessor | R Documentation |
Apply a trained Preprocessor to new data, reusing the values learned from the training
data. For example, the same mean and mode imputation values, scale centers and
coefficients, one-hot levels, and removed features will be applied to the new data.
apply_preprocessor(preprocessor, new_data, verbosity = 1L)
preprocessor |
|
new_data |
Tabular data, i.e. data.frame, data.table, or tbl_df (tibble): New data to preprocess. |
verbosity |
Integer: Verbosity level. |
Imputation follows the preprocessor's impute_type. "meanMode" imputes the
stored training values. "missRanger" applies the forests fitted on the
training data with predict(), and imputes a feature that had no missing
training values with its stored mean or mode; predict() stops on a factor
level of an imputed feature that is absent from the training data. A
preprocessor using "micePMM" cannot be applied to new data and is refused.
Preprocessed data, in the same structure as new_data.
EDG
preprocess, setup_Preprocessor
res <- resample(iris, setup_KFold(seed = 2026))
iris_train <- iris[res[[1]], ]
iris_test <- iris[-res[[1]], ]
# Preprocess training data
iris_pre <- preprocess(iris_train, setup_Preprocessor(scale = TRUE, center = TRUE))
# Apply the same preprocessing to test data
iris_test_pre <- apply_preprocessor(iris_pre, iris_test)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.