matrix.interaction | R Documentation |
Creates a matrix with pairwise interactions.
matrix.interaction(
mat,
intr_keys = NULL,
intr_values,
levels = NULL,
n_threads = 1
)
mat |
The dense matrix, which can include factors with levels coded as non-negative integers. |
intr_keys |
List of feature indices. This is a list of all features with which interactions can be formed. Default is |
intr_values |
List of list of feature indices. For each of the |
levels |
Number of levels for each of the columns of |
n_threads |
Number of threads. |
Pairwise interaction matrix. Logic is used to avoid repetitions. For each factor variable, the column is one-hot-encoded to form a basis for that feature. 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.
Trevor Hastie and James Yang
Maintainer: Trevor Hastie hastie@stanford.edu
n <- 10
p <- 20
X_dense <- matrix(rnorm(n * p), n, p)
X_dense[,1] <- rbinom(n, 4, 0.5)
intr_keys <- c(1, 2)
intr_values <- list(NULL, c(1, 3))
levels <- c(c(5), rep(1, p-1))
out <- matrix.interaction(X_dense, intr_keys, intr_values, levels)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.