whm_lda | R Documentation |
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.
whm_lda(X, labels, m)
X |
A numeric matrix of size |
labels |
A vector of length |
m |
The number of dimensions to reduce to, i.e., the number of columns in the projection matrix |
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:
Compute the between-class (S_b
) and within-class (S_w
) scatter matrices.
Initialize a projection matrix W
(of size d x m
) randomly and ensure it is orthonormal.
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.
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
.
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"
.
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.
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.