R: Apply a Trained Data Recipe

bake {recipes} | R Documentation

## Apply a Trained Data Recipe

### Description

For a recipe with at least one preprocessing operations that has been trained by `prep.recipe()`, apply the computations to new data.

### Usage

    bake(object, ...)

    ## S3 method for class 'recipe'
    bake(object, newdata, ..., composition = "tibble")

### Arguments

`object` | A trained object such as a `recipe()` with at least one preprocessing operation.
`...` | One or more selector functions to choose which variables will be returned by the function. See `selections()` for more details. If no selectors are given, the default is to use `everything()`.
`newdata` | A data frame or tibble for whom the preprocessing will be applied.
`composition` | Either "tibble", "matrix", or "dgCMatrix" for the format of the processed data set. Note that all computations during the baking process are done in a non-sparse format. Also, note that this argument should be called after any selectors and the selectors should only resolve to numeric columns (otherwise an error is thrown).

### Details

`bake()` takes a trained recipe and applies the operations to a data set to create a design matrix.

If the original data used to train the data are to be processed, time can be saved by using the `retain = TRUE` option of `prep()` to avoid duplicating the same operations. With this option set, `juice()` can be used instead of `bake` with `newdata` equal to the training set.

Also, any steps with `skip = TRUE` will not be applied to the data when `bake` is invoked. `juice()` will always have all of the steps applied.

### Value

A tibble, matrix, or sparse matrix that may have different columns than the original columns in `newdata`.

### Author(s)

Max Kuhn

### See Also

`recipe()`, `juice()`, `prep()`

[Package recipes version 0.1.2 Index]