matrix.one_hot | R Documentation |
Creates a one-hot encoded matrix.
matrix.one_hot(mat, levels = NULL, n_threads = 1)
mat |
A dense matrix, which can include factors with levels coded as non-negative integers. |
levels |
Number of levels for each of the columns of |
n_threads |
Number of threads. |
One-hot encoded matrix. All the factor columns, with levels>1, are replaced by a collection of one-hot encoded versions (dummy matrices). The resulting matrix has sum(levels)
columns.
The object is an S4 class with methods for efficient computation by adelie. Note that some of the arguments are transformed to C++ base 0 for internal use, and if the object is examined, it will reflect that.
James Yang, Trevor Hastie, and Balasubramanian Narasimhan
Maintainer: Trevor Hastie hastie@stanford.edu
n <- 100
p <- 20
mat <- matrix(rnorm(n * p), n, p)
out <- matrix.one_hot(mat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.