gmmsd: Generalized Multiple Maximum Scatter Difference (GMMSD)

View source: R/gmmsd.R

gmmsdR Documentation

Generalized Multiple Maximum Scatter Difference (GMMSD)

Description

This function implements the GMMSD method for feature extraction. It solves a generalized eigenvalue problem to find a projection that maximizes the difference between the between-class scatter and a scaled within-class scatter. The method uses a QR decomposition to enhance computational efficiency, making it suitable for high-dimensional data.

Usage

gmmsd(X, y, c = 1, dim = 2, preproc = multivarious::center())

Arguments

X

A numeric matrix (n x d), where n is the number of samples (rows) and d is the number of features (columns).

y

A factor or numeric vector of length n representing class labels for each sample. If numeric, it will be internally converted to a factor.

c

A numeric balance parameter scaling the within-class scatter matrix. Typically a positive value. Default is 1.

dim

The number of dimensions (features) to retain in the transformed feature space.

preproc

A pre_processor object from multivarious (e.g. center(), scale()). Defaults to center().

Value

A discriminant_projector object (subclass can be "gmmsd") containing:

  • v : A d x dim loading/projection matrix.

  • s : An n x dim score matrix (the data projected onto the new axes).

  • sdev : Standard deviations of each dimension in s.

  • labels: The class labels.

  • preproc: The preprocessing object used.

Examples

## Not run: 
library(multivarious)

data(iris)
X <- as.matrix(iris[, -5])
y <- iris$Species

# By default, this will center the data prior to GMMSD
dp <- gmmsd(X, y, c = 1, dim = 2)

# Inspect the projector
print(dp)

# Project the original data
scores <- dp$s
# or equivalently, project(dp, X)

## End(Not run)

bbuchsbaum/discursive documentation built on April 14, 2025, 4:57 p.m.