whm_lda: Weighted Harmonic Mean of Trace Ratios for Multiclass...

View source: R/whm_lda.R

whm_ldaR Documentation

Weighted Harmonic Mean of Trace Ratios for Multiclass Discriminant Analysis

Description

This function implements the Weighted Harmonic Mean of Trace Ratios (WHM-TR) method for multiclass discriminant analysis as described in the referenced paper. The goal is to find a linear transformation W that improves class separability by minimizing the weighted harmonic mean of trace ratios derived from the between-class and within-class scatter matrices.

Usage

whm_lda(X, labels, m)

Arguments

X

A numeric matrix of size n x d, where n is the number of samples and d is the number of features. Rows correspond to samples and columns to features.

labels

A vector of length n containing the class labels of the samples. Can be a factor or a numeric vector.

m

The number of dimensions to reduce to, i.e., the number of columns in the projection matrix W.

Details

The algorithm implemented here follows the approach described in Li et al. (2017), "Beyond Trace Ratio: Weighted Harmonic Mean of Trace Ratios for Multiclass Discriminant Analysis." The method proceeds as follows:

  1. Compute the between-class (S_b) and within-class (S_w) scatter matrices.

  2. Initialize a projection matrix W (of size d x m) randomly and ensure it is orthonormal.

  3. Iteratively update W by minimizing the weighted harmonic mean of trace ratios. This involves:

    • Evaluating pairs of classes and computing partial scatter matrices for each pair.

    • Updating W by solving an eigen-decomposition problem derived from these intermediate matrices.

  4. Stop when convergence is reached (based on a tolerance) or after a maximum number of iterations.

After convergence, W is returned in a standard discriminant_projector format, along with the reduced data XW in s.

Value

A discriminant_projector object with:

  • v: The projection matrix W of size d x m.

  • s: The transformed data X W of size n x m.

  • sdev: The standard deviations of each column in s.

  • labels: The original labels if provided (as a factor).

  • classes: set to "whm_lda".

References

Li, Zhihui, et al. "Beyond Trace Ratio: Weighted Harmonic Mean of Trace Ratios for Multiclass Discriminant Analysis." IEEE Transactions on Knowledge and Data Engineering (TKDE), 2017.

Examples

## Not run: 
data(iris)
X <- as.matrix(iris[,1:4])
labels <- iris[,5]
proj <- whm_lda(X, labels, m=2)
print(proj)
# Now you can do:
# new_data <- ...
# projected <- project(proj, new_data)

## End(Not run)


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