step_pareto creates a specification of a recipe step that will perform Pareto scaling on the columns.

step_pareto(
  recipe,
  ...,
  role = NA,
  trained = FALSE,
  means = NULL,
  sdroots = NULL,
  na_rm = TRUE,
  skip = FALSE,
  id = rand_id("pareto")
)

# S3 method for step_pareto
tidy(x, ...)

Arguments

recipe

A recipe object. The step will be added to the sequence of operations for this recipe.

...

One or more selector functions to choose which variables are affected by the step. See selections() for more details. For the tidy method, these are not currently used.

role

Not used by this step since no new variables are created.

trained

A logical to indicate if the quantities for preprocessing have been estimated.

means

A named numeric vector of means. This is NULL until computed by prep.recipe().

sdroots

A named numeric vector of standard deviation square roots. This is NULL until computed by prep.recipe().

na_rm

A logical value indicating whether NA values should be removed when computing the standard deviation and mean.

skip

A logical. Should the step be skipped when the recipe is baked by bake.recipe()? While all operations are baked when prep.recipe() is run, some operations may not be able to be conducted on new data (e.g. processing the outcome variable(s)). Care should be taken when using skip = TRUE as it may affect the computations for subsequent operations

id

A character string that is unique to this step to identify it.

x

A step_pareto object.

Value

An updated version of recipe with the new step added to the sequence of existing steps (if any). For the tidy method, a tibble with columns terms (the selectors or variables selected), value (the standard deviations and means), and statistic for the type of value.

Details

Pareto scaling is a variant of autoscaling whereby the data is scaled by the square root of its standard deviation. step_pareto estimates the standard deviations and means from the data used in the training argument of prep.recipe. bake.recipe then applies the scaling to new data sets using these estimates.

References

van den Berg, R. A., Hoefsloot, H. C., Westerhuis, J. A., Smilde, A. K., & van der Werf, M. J. (2006). Centering, scaling, and transformations: improving the biological information content of metabolomics data. BMC genomics, 7, 142. https://doi.org/10.1186/1471-2164-7-142 https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1534033/

Examples

library(tidySpectR) library(recipes) pareto <- recipe(Species ~. , iris) %>% step_pareto(all_predictors())