onehot_encoder: onehot_encoder

Description Usage Arguments Value Examples

View source: R/onehot_encoder.R

Description

This function encodes categorical variables using the popular onehot method for each category.

Usage

1
onehot_encoder(X_train, X_test = NULL, cat_columns)

Arguments

X_train

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

X_test

X_test A 'tibble' or 'data.frame' representing the test set, containing some set of categorical features/columns. Default = NULL.

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, in which the named categorical columns are replaced with their encodings.

Examples

1
2
3
onehot_encoder(
X_train = mtcars,
cat_columns = c("gear", "carb"))

UBC-MDS/encodeR documentation built on March 31, 2020, 12:53 a.m.