# Setup a `Preprocessor`: this outputs a `PreprocessorConfig` object.
prp <- setup_Preprocessor(remove_duplicates = TRUE, scale = TRUE, center = TRUE)
# Includes a long list of parameters
prp
# Resample iris to get train and test data
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, prp)
# Alternatively, for interactive use, pass `setup_Preprocessor()` arguments directly
iris_pre <- preprocess(iris_train, remove_duplicates = TRUE, scale = TRUE, center = TRUE)
# Access preprocessed training data with `preprocessed()`
preprocessed(iris_pre)
# Apply the same preprocessing to test data with `apply_preprocessor()`,
# which returns the preprocessed data directly.
# The scale and center values learned from the training data will be used.
iris_test_pre <- apply_preprocessor(iris_pre, iris_test)
Run the code above in your browser using DataLab