preprocess_functions {cvms}R Documentation

Examples of preprocess_fn functions



Examples of preprocess functions that can be used in cross_validate_fn() and validate_fn(). They can either be used directly or be starting points.

The examples use recipes, but you can also use caret::preProcess() or similar functions.

In these examples, the preprocessing will only affect the numeric predictors.

You may prefer to hardcode a formula like "y ~ ." (where y is your dependent variable) as that will allow you to set 'preprocess_one' to TRUE in cross_validate_fn() and validate_fn() and save time.





Name of preprocessing function as it appears in the following list:

Name Description
"standardize" Centers and scales the numeric predictors
"range" Normalizes the numeric predictors to the 0-1 range
"scale" Scales the numeric predictors to have a standard deviation of one
"center" Centers the numeric predictors to have a mean of zero
"warn" Identity function that throws a warning and a message


A function with the following form:

function(train_data, test_data, formula, hyperparameters) {

⁠ ⁠# Preprocess train_data and test_data

⁠ ⁠# Return a list with the preprocessed datasets

⁠ ⁠# and optionally a data frame with preprocessing parameters

⁠ ⁠list(

⁠ ⁠"train" = train_data,

⁠ ⁠"test" = test_data,

⁠ ⁠"parameters" = tidy_parameters

⁠ ⁠)



Ludvig Renbo Olsen,

See Also

Other example functions: model_functions(), predict_functions(), update_hyperparameters()

[Package cvms version 1.3.3 Index]