Convert a vector of unordered categorical data (either numeric or character labels) to a "one-hot" encoded matrix in which a 1 in a column indicates the presence of the relevant category.
oneHotInitializeAndEncode.Rd
To allow for prediction on "unseen" categories in a test dataset, this
procedure pads the one-hot matrix with a blank "other" column.
Test set observations that contain categories not in levels(factor(x_input))
will all be mapped to this column.
Value
List containing a binary one-hot matrix and the unique levels of the input variable. These unique levels are used in the BCF and BART functions.
Examples
x <- c("a","c","b","c","d","a","c","a","b","d")
x_onehot <- oneHotInitializeAndEncode(x)