discriminant_projector: Construct a Discriminant Projector

View source: R/discriminant_projector.R

discriminant_projectorR Documentation

Construct a Discriminant Projector

Description

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).

Usage

discriminant_projector(
  v,
  s,
  sdev,
  preproc = prep(pass()),
  labels,
  classes = NULL,
  ...
)

Arguments

v

A matrix of coefficients with dimensions nrow(v) by ncol(v) (number of columns = number of components)

s

The score matrix

sdev

The standard deviations of the score matrix

preproc

(optional) A pre-processing pipeline, default is prep(pass())

labels

A factor or character vector of class labels corresponding to the rows of the score matrix s.

classes

(optional) A character vector specifying the class attributes of the object, default is NULL

...

Extra arguments to be stored in the projector object.

Value

A discriminant_projector object.

See Also

bi_projector

Examples

# 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)

bbuchsbaum/multivarious documentation built on April 15, 2024, 3:33 a.m.