make_recipe: make_recipe Documentation

Description Usage Arguments Value The recipe parameter Examples

View source: R/make_recipe.R

Description

The make_recipe() function is used to quickly apply common data preprocessing techniques

Usage

1
2
3
4
5
6
7
8
make_recipe(
  X,
  y,
  recipe,
  splits_to_return = "train_test",
  random_seed = NULL,
  train_valid_prop = 0.8
)

Arguments

X

A dataframe containing training data, validation data, and testing data (should contain X and y).

y

The name of the response column (as a string, e.g. "response_variable").

recipe

A string specifying which recipe to apply to the data. See "The recipe parameter" section below for details.

splits_to_return

A string specifying how to split the data. "train_test" to return train and test splits, "train_test_valid" to return train, test, and validation data, "train" to return all data without splits.

random_seed

An integer. The random seed to set for splitting data to create reproducible results. By default NULL

train_valid_prop

A float. The proportion to split the data by. Should range between 0 to 1. By default = 0.8

Value

A list of dataframes e.g. list(X_train, X_valid, X_test, y_train, y_valid, y_test)

The recipe parameter

The following recipes are available currently to pass into the recipe parameter:

More recipes are under development and will be released in future updates.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# apply "ohe_and_standard_scaler" on training and testing data
X_example <- dplyr::as_tibble(mtcars) %>%
  dplyr::mutate(
    carb = as.factor(carb),
    gear = as.factor(gear),
    vs = as.factor(vs),
    am = as.factor(am)
  )
y_example <- "gear"
make_recipe(X = X_example, y = y_example, recipe = "ohe_and_standard_scaler", splits_to_return = "train_test")

UBC-MDS/mealprepR documentation built on April 1, 2020, 4:36 a.m.