public class FLD extends java.lang.Object implements Classifier<double[]>, Projection<double[]>
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 FormConstructor and Description |
---|
FLD(double[] mean,
double[][] mu,
smile.math.matrix.Matrix scaling)
Constructor.
|
FLD(double[] mean,
double[][] mu,
smile.math.matrix.Matrix scaling,
smile.util.IntSet labels)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static FLD |
fit(double[][] x,
int[] y)
Learn Fisher's linear discriminant.
|
static FLD |
fit(double[][] x,
int[] y,
int L,
double tol)
Learn Fisher's linear discriminant.
|
static FLD |
fit(smile.data.formula.Formula formula,
smile.data.DataFrame data)
Learn Fisher's linear discriminant.
|
static FLD |
fit(smile.data.formula.Formula formula,
smile.data.DataFrame data,
java.util.Properties prop)
Learn Fisher's linear discriminant.
|
smile.math.matrix.Matrix |
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 to the feature space.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
applyAsDouble, applyAsInt, f, predict
public FLD(double[] mean, double[][] mu, smile.math.matrix.Matrix scaling)
mean
- the mean vector of all samples.mu
- the mean vectors of each class.scaling
- the projection matrix.public FLD(double[] mean, double[][] mu, smile.math.matrix.Matrix scaling, smile.util.IntSet labels)
mean
- the mean vector of all samples.mu
- the mean vectors of each class - mean.scaling
- the projection matrix.labels
- class labelspublic static FLD fit(smile.data.formula.Formula formula, smile.data.DataFrame data)
formula
- a symbolic description of the model to be fitted.data
- the data frame of the explanatory and response variables.public static FLD fit(smile.data.formula.Formula formula, smile.data.DataFrame data, java.util.Properties prop)
formula
- a symbolic description of the model to be fitted.data
- the data frame of the explanatory and response variables.public static FLD fit(double[][] x, int[] y)
x
- training samples.y
- training labels.public static FLD fit(double[][] x, int[] y, int L, double tol)
x
- training samples.y
- training labels.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 smile.math.matrix.Matrix getProjection()