Skip to contents

Apply a trained Preprocessor to new data, reusing the values learned from the training data. For example, the same scale centers and coefficients, one-hot levels, and removed features will be applied to the new data.

Usage

apply_preprocessor(preprocessor, new_data, verbosity = 1L)

Arguments

preprocessor

Preprocessor: Trained preprocessor, i.e. the output of preprocess.

new_data

data.frame or data.table: New data to preprocess.

verbosity

Integer: Verbosity level.

Value

Preprocessed data of the same class as new_data (data.frame or data.table).

Author

EDG

Examples

res <- resample(iris, setup_Resampler(seed = 2026))
#> 2026-08-09 13:22:20 
#> Using max n bins possible = 3.
#>  [kfold]
iris_train <- iris[res[[1]], ]
iris_test <- iris[-res[[1]], ]

# Preprocess training data
iris_pre <- preprocess(iris_train, setup_Preprocessor(scale = TRUE, center = TRUE))
#> 2026-08-09 13:22:20 
#> Scaling and centering 4 numeric features...
#>  [preprocess]
#> 2026-08-09 13:22:20 
#> Preprocessing done.
#>  [preprocess]

# Apply the same preprocessing to test data
iris_test_pre <- apply_preprocessor(iris_pre, iris_test)
#> 2026-08-09 13:22:20 
#> Scaling and centering 4 numeric features...
#>  [preprocess]
#> 2026-08-09 13:22:20 
#> Preprocessing done.
#>  [preprocess]