one.hot {liver} | R Documentation |
One Hot Encoder
Description
One-Hot-Encode unordered factor columns of a data.frame, matrix, or data.table, using the
mltools::one_hot()
mltools::one_hot function.
Usage
one.hot(data, cols = "auto", sparsifyNAs = FALSE, naCols = FALSE,
dropCols = TRUE, dropUnusedLevels = FALSE)
Arguments
data |
a numerical |
cols |
a character vector of column names or indices to one-hot-encode. If |
sparsifyNAs |
a logical value indicating whether to converte NAs to 0s. |
naCols |
a logical value indicating whether to create a separate column for NAs. |
dropCols |
a logical value indicating whether to drop the original columns which are one-hot-encoded. |
dropUnusedLevels |
a logical value indicating whether to drop unused factor levels. |
Author(s)
Reza Mohammadi a.mohammadi@uva.nl and Kevin Burke kevin.burke@ul.ie
See Also
Examples
data(risk)
str(risk)
risk_oh <- one.hot(risk, cols = "auto")
str(risk_oh)
[Package liver version 1.19 Index]