public class QDA extends java.lang.Object implements SoftClassifier<double[]>
The Gaussian parameters for each class can be estimated from training data
with maximum likelihood (ML) estimation. However, when the number of
training instances is small compared to the dimension of input space,
the ML covariance estimation can be ill-posed. One approach to resolve
the ill-posed estimation is to regularize the covariance estimation.
One of these regularization methods is regularized discriminant analysis
.
LDA
,
RDA
,
NaiveBayes
,
Serialized FormConstructor and Description |
---|
QDA(double[] priori,
double[][] mu,
double[][] eigen,
smile.math.matrix.DenseMatrix[] scaling)
Constructor.
|
QDA(double[] priori,
double[][] mu,
double[][] eigen,
smile.math.matrix.DenseMatrix[] scaling,
smile.util.IntSet labels)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static QDA |
fit(double[][] x,
int[] y)
Learn quadratic discriminant analysis.
|
static QDA |
fit(double[][] x,
int[] y,
double[] priori,
double tol)
Learn quadratic discriminant analysis.
|
static QDA |
fit(double[][] x,
int[] y,
java.util.Properties prop)
Learns quadratic discriminant analysis.
|
static QDA |
fit(smile.data.formula.Formula formula,
smile.data.DataFrame data)
Learns quadratic discriminant analysis.
|
static QDA |
fit(smile.data.formula.Formula formula,
smile.data.DataFrame data,
java.util.Properties prop)
Learns quadratic discriminant analysis.
|
int |
predict(double[] x)
Predicts the class label of an instance.
|
int |
predict(double[] x,
double[] posteriori)
Predicts the class label of an instance and also calculate a posteriori
probabilities.
|
double[] |
priori()
Returns a priori probabilities.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
applyAsDouble, applyAsInt, f, predict
public QDA(double[] priori, double[][] mu, double[][] eigen, smile.math.matrix.DenseMatrix[] scaling)
priori
- a priori probabilities of each class.mu
- the mean vectors of each class.eigen
- the eigen values of each variance matrix.scaling
- the eigen vectors of each covariance matrix.public QDA(double[] priori, double[][] mu, double[][] eigen, smile.math.matrix.DenseMatrix[] scaling, smile.util.IntSet labels)
priori
- a priori probabilities of each class.mu
- the mean vectors of each class.eigen
- the eigen values of each variance matrix.scaling
- the eigen vectors of each covariance matrix.labels
- class labelspublic static QDA 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 QDA 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 QDA fit(double[][] x, int[] y)
x
- training samples.y
- training labels in [0, k), where k is the number of classes.public static QDA fit(double[][] x, int[] y, java.util.Properties prop)
x
- training samples.y
- training labels.public static QDA fit(double[][] x, int[] y, double[] priori, double tol)
x
- training samples.y
- training labels in [0, k), where k is the number of classes.priori
- the priori probability of each class. If null, it will be
estimated from the training data.tol
- a tolerance to decide if a covariance matrix is singular; it
will reject variables whose variance is less than tol2.public double[] priori()
public int predict(double[] x)
Classifier
predict
in interface Classifier<double[]>
x
- the instance to be classified.public int predict(double[] x, double[] posteriori)
SoftClassifier
predict
in interface SoftClassifier<double[]>
x
- an instance to be classified.posteriori
- the array to store a posteriori probabilities on output.