public class FLD extends java.lang.Object implements Classifier<double[]>, Projection<double[]>, java.io.Serializable
The terms Fisher's linear discriminant and LDA are often used interchangeably, although FLD actually describes a slightly different discriminant, which does not make some of the assumptions of LDA such as normally distributed classes or equal class covariances. When the assumptions of LDA are satisfied, FLD is equivalent to LDA.
FLD is also closely related to principal component analysis (PCA), which also looks for linear combinations of variables which best explain the data. As a supervised method, FLD explicitly attempts to model the difference between the classes of data. On the other hand, PCA is a unsupervised method and does not take into account any difference in class.
One complication in applying FLD (and LDA) to real data occurs when the number of variables/features does not exceed the number of samples. In this case, the covariance estimates do not have full rank, and so cannot be inverted. This is known as small sample size problem.
LDA
,
PCA
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
FLD.Trainer
Trainer for Fisher's linear discriminant.
|
Constructor and Description |
---|
FLD(double[][] x,
int[] y)
Constructor.
|
FLD(double[][] x,
int[] y,
int L)
Constructor.
|
FLD(double[][] x,
int[] y,
int L,
double tol)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
double[][] |
getProjection()
Returns the projection matrix W.
|
int |
predict(double[] x)
Predicts the class label of an instance.
|
double[] |
project(double[] x)
Project a data point to the feature space.
|
double[][] |
project(double[][] x)
Project a set of data toe the feature space.
|
public FLD(double[][] x, int[] y)
x
- training instances.y
- training labels in [0, k), where k is the number of classes.public FLD(double[][] x, int[] y, int L)
x
- training instances.y
- training labels in [0, k), where k is the number of classes.L
- the dimensionality of mapped space.public FLD(double[][] x, int[] y, int L, double tol)
x
- training instances.y
- training labels in [0, k), where k is the number of classes.L
- the dimensionality of mapped space.tol
- a tolerance to decide if a covariance matrix is singular; it
will reject variables whose variance is less than tol2.public int predict(double[] x)
Classifier
predict
in interface Classifier<double[]>
x
- the instance to be classified.public double[] project(double[] x)
Projection
project
in interface Projection<double[]>
public double[][] project(double[][] x)
Projection
project
in interface Projection<double[]>
public double[][] getProjection()