matrix.one_hot {adelie} | R Documentation |
Creates a one-hot encoded matrix.
Description
Creates a one-hot encoded matrix.
Usage
matrix.one_hot(mat, levels = NULL, n_threads = 1)
Arguments
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. |
Value
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.
Author(s)
James Yang, Trevor Hastie, and Balasubramanian Narasimhan
Maintainer: Trevor Hastie hastie@stanford.edu
Examples
n <- 100
p <- 20
mat <- matrix(rnorm(n * p), n, p)
out <- matrix.one_hot(mat)