Description Usage Arguments Value The recipe parameter Examples
The make_recipe()
function is used to quickly apply common data preprocessing techniques
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
)
|
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 |
A list of dataframes e.g. list(X_train, X_valid, X_test, y_train, y_valid, y_test)
The following recipes are available currently to pass into the recipe
parameter:
"ohe_and_standard_scaler" - Apply one hot encoding to categorical features and standard scaler to numeric features
More recipes are under development and will be released in future updates.
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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.