smile.classification
Class RDA
- java.lang.Object
-
- smile.classification.RDA
-
- All Implemented Interfaces:
- java.io.Serializable, Classifier<double[]>, SoftClassifier<double[]>
public class RDA extends java.lang.Object implements SoftClassifier<double[]>, java.io.Serializable
Regularized discriminant analysis. RDA is a compromise between LDA and QDA, which allows one to shrink the separate covariances of QDA toward a common variance as in LDA. This method is very similar in flavor to ridge regression. The regularized covariance matrices of each class is Σk(α) = α Σk + (1 - α) Σ. The quadratic discriminant function is defined using the shrunken covariance matrices Σk(α). The parameter α in [0, 1] controls the complexity of the model. When α is one, RDA becomes QDA. While α is zero, RDA is equivalent to LDA. Therefore, the regularization factor α allows a continuum of models between LDA and QDA.- See Also:
LDA,QDA, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classRDA.TrainerTrainer for regularized discriminant analysis.
-
Constructor Summary
Constructors Constructor and Description RDA(double[][] x, int[] y, double alpha)Constructor.RDA(double[][] x, int[] y, double[] priori, double alpha)Constructor.RDA(double[][] x, int[] y, double[] priori, double alpha, double tol)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description double[]getPriori()Returns a priori probabilities.intpredict(double[] x)Predicts the class label of an instance.intpredict(double[] x, double[] posteriori)Predicts the class label of an instance and also calculate a posteriori probabilities.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface smile.classification.Classifier
predict
-
-
-
-
Constructor Detail
-
RDA
public RDA(double[][] x, int[] y, double alpha)Constructor. Learn regularized discriminant analysis.- Parameters:
x- training samples.y- training labels in [0, k), where k is the number of classes.alpha- regularization factor in [0, 1] allows a continuum of models between LDA and QDA.
-
RDA
public RDA(double[][] x, int[] y, double[] priori, double alpha)Constructor. Learn regularized discriminant analysis.- Parameters:
x- training samples.y- training labels in [0, k), where k is the number of classes.alpha- regularization factor in [0, 1] allows a continuum of models between LDA and QDA.priori- the priori probability of each class.
-
RDA
public RDA(double[][] x, int[] y, double[] priori, double alpha, double tol)Constructor. Learn regularized discriminant analysis.- Parameters:
x- training samples.y- training labels in [0, k), where k is the number of classes.alpha- regularization factor in [0, 1] allows a continuum of models between LDA and QDA.priori- the priori probability of each class.tol- tolerance to decide if a covariance matrix is singular; it will reject variables whose variance is less than tol2.
-
-
Method Detail
-
getPriori
public double[] getPriori()
Returns a priori probabilities.
-
predict
public int predict(double[] x)
Description copied from interface:ClassifierPredicts the class label of an instance.- Specified by:
predictin interfaceClassifier<double[]>- Parameters:
x- the instance to be classified.- Returns:
- the predicted class label.
-
predict
public int predict(double[] x, double[] posteriori)Description copied from interface:SoftClassifierPredicts the class label of an instance and also calculate a posteriori probabilities. Classifiers may NOT support this method since not all classification algorithms are able to calculate such a posteriori probabilities.- Specified by:
predictin interfaceSoftClassifier<double[]>- Parameters:
x- the instance to be classified.posteriori- the array to store a posteriori probabilities on output.- Returns:
- the predicted class label
-
-
DataMelt 3.0 © DataMelt by jWork.ORG