For a recipe with at least one preprocessing operation, estimate the required parameters from a training set that can be later applied to other data sets.
prep(x, ...) # S3 method for recipe prep( x, training = NULL, fresh = FALSE, verbose = FALSE, retain = TRUE, strings_as_factors = TRUE, ... )
further arguments passed to or from other methods (not currently used).
A data frame or tibble that will be used to estimate parameters for preprocessing.
A logical indicating whether already trained operation should be
A logical that controls whether progress is reported as operations are executed.
A logical: should the preprocessed training set be saved
A logical: should character columns be converted to
factors? This affects the preprocessed training set (when
A recipe whose step objects have been updated with the required
quantities (e.g. parameter estimates, model objects, etc). Also, the
term_info object is likely to be modified as the operations are
Given a data set, this function estimates the required quantities and statistics required by any operations.
prep() returns an updated recipe with the estimates.
Note that missing data handling is handled in the steps; there is no global
na.rm option at the recipe-level or in
Also, if a recipe has been trained using
prep() and then steps
prep() will only update the new operations. If
fresh = TRUE, all of the operations will be (re)estimated.
As the steps are executed, the
training set is updated. For example,
if the first step is to center the data and the second is to scale the
data, the step for scaling is given the centered data.