one_hot_encoding {creditmodel} | R Documentation |
One-Hot Encoding
Description
one_hot_encoding
is for converting the factor or character variables into multiple columns
Usage
one_hot_encoding(
dat,
cat_vars = NULL,
ex_cols = NULL,
merge_cat = TRUE,
na_act = TRUE,
note = FALSE
)
Arguments
dat |
A dat frame. |
cat_vars |
The name or Column index list to be one_hot encoded. |
ex_cols |
Variables to be excluded, use regular expression matching |
merge_cat |
Logical. If TRUE, to merge categories greater than 8, default is TRUE. |
na_act |
Logical,If true, the missing value is processed, if FALSE missing value is omitted . |
note |
Logical.Outputs info.Default is TRUE. |
Value
A dat frame with the one hot encoding applied to all the variables with type as factor or character.
See Also
Examples
dat1 = one_hot_encoding(dat = UCICreditCard,
cat_vars = c("SEX", "MARRIAGE"),
merge_cat = TRUE, na_act = TRUE)
dat2 = de_one_hot_encoding(dat_one_hot = dat1,
cat_vars = c("SEX","MARRIAGE"), na_act = FALSE)
[Package creditmodel version 1.3.1 Index]