pub struct Lda { /* private fields */ }Expand description
Fisher’s linear discriminant analysis: a supervised projection that maximises the ratio of
between-class to within-class scatter, so classes are pulled apart while each is kept compact.
At most classes - 1 discriminant directions exist. The same model doubles as a classifier
(nearest class mean in the projected space, adjusted by log-priors), which is the Gaussian
classifier with a shared covariance.
The generalised eigenproblem S_b w = λ S_w w is solved by whitening with the Cholesky factor
of the (slightly regularised) within-class scatter.
Implementations§
Source§impl Lda
impl Lda
Sourcepub fn new(components: usize) -> Self
pub fn new(components: usize) -> Self
Keeps components discriminant directions (at most classes - 1).
Sourcepub fn with_shrinkage(self, shrinkage: f64) -> Self
pub fn with_shrinkage(self, shrinkage: f64) -> Self
Sets the ridge added to the within-class scatter, as a fraction of its mean diagonal; use a
larger value (for example 0.1) when features are nearly collinear or samples are few.
Sourcepub fn eigenvalues(&self) -> &[f64]
pub fn eigenvalues(&self) -> &[f64]
The Fisher criterion value (between/within scatter ratio) of each kept direction.