View source: R/discriminant_projector.R
discriminant_projector | R Documentation |
A discriminant_projector
is an instance that extends bi_projector
with a projection that maximizes class separation.
This can be useful for dimensionality reduction techniques that take class labels into account, such as Linear Discriminant Analysis (LDA).
discriminant_projector(
v,
s,
sdev,
preproc = prep(pass()),
labels,
classes = NULL,
...
)
v |
The projection matrix (often |
s |
The score matrix (often |
sdev |
The standard deviations associated with the scores or components (e.g., singular values from LDA). |
preproc |
A |
labels |
A factor or character vector of class labels corresponding to the rows of |
classes |
Additional S3 classes to prepend. |
... |
Extra arguments passed to |
A discriminant_projector
object.
bi_projector
# Simulate data and labels
set.seed(123)
X <- matrix(rnorm(100 * 10), 100, 10)
labels <- factor(rep(1:2, each = 50))
# Perform LDA and create a discriminant projector
lda_fit <- MASS::lda(X, labels)
dp <- discriminant_projector(lda_fit$scaling, X %*% lda_fit$scaling, sdev = lda_fit$svd,
labels = labels)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.