one_hot_encode.Rd
One-hot encoding
one_hot_encode(y)
A vector of class labels
The number of classes
A matrix of one-hot encoded labels
y <- as.factor(c(1, 2, 1, 1, 2)) misc::one_hot_encode(y) #> [,1] [,2] #> [1,] 1 0 #> [2,] 0 1 #> [3,] 1 0 #> [4,] 1 0 #> [5,] 0 1