This function encodes categorical variables using the frequencies of each category.

frequency_encoder(X_train, X_test = NULL, cat_columns)

Arguments

X_train

A `tibble` or `data.frame` representing the training data set containing some categorical features/columns.

X_test

A `tibble` or `data.frame` representing the test set, containing some set of categorical features/columns.

cat_columns

A character vector containing the names of the categorical columns in the tibble that should be encoded.

Value

A `list` with processed training and test sets (if provided), in which the named categorical columns are replaced with their encodings.

Examples

frequency_encoder( X_train = mtcars, cat_columns = c("gear", "carb"))
#> Joining, by = "gear"
#> Joining, by = "carb"