Type: | Package |
Title: | Fast Onehot Encoding for Data.frames |
Version: | 0.1.1 |
Author: | Eric E. Graves [aut, cre] |
Maintainer: | Eric E. Graves <gravcon5@gmail.com> |
Description: | Quickly create numeric matrices for machine learning algorithms that require them. It converts factor columns into onehot vectors. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 6.0.1 |
NeedsCompilation: | yes |
Packaged: | 2017-05-02 13:12:03 UTC; GravesEE |
Repository: | CRAN |
Date/Publication: | 2017-05-02 16:13:01 UTC |
Onehot encode a data.frame
Description
Onehot encode a data.frame
Usage
onehot(data, stringsAsFactors = FALSE, addNA = FALSE, max_levels = 10)
Arguments
data |
data.frame to convert factors into onehot encoded columns |
stringsAsFactors |
if TRUE, converts character vectors to factors |
addNA |
if TRUE, adds NA to factors as a level |
max_levels |
maximum number of levels to onehot encode per factor variable. Factors with levels exceeding this number will be skipped. |
Value
a onehot
object descrbing how to transform the data
Examples
data(iris)
encoder <- onehot(iris)
## add NAs to factors
encoder <- onehot(iris, addNA=TRUE)
## Convert character fields to factrs
encoder <- onehot(iris, stringsAsFactors=TRUE)
## limit which factors are onehot encoded
encoder <- onehot(iris, max_levels=5)
Predict onehot objects
Description
Predict onehot objects
Usage
## S3 method for class 'onehot'
predict(object, data, ...)
Arguments
object |
an object of class |
data |
a data.frame to onehot encode useing |
... |
further arguments passed to or from other methods |
Value
a matrix with factor variable onehot encoded
Examples
data(iris)
encoder <- onehot(iris)
x <- predict(encoder, iris)