smile.classification

## Class RDA

• All Implemented Interfaces:
java.io.Serializable, java.util.function.ToDoubleFunction<double[]>, java.util.function.ToIntFunction<double[]>, Classifier<double[]>, SoftClassifier<double[]>

```public class RDA
extends QDA```
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.
`LDA`, `QDA`, Serialized Form
• ### Constructor Summary

Constructors
Constructor and Description
```RDA(double[] priori, double[][] mu, double[][] eigen, Matrix[] scaling)```
Constructor.
```RDA(double[] priori, double[][] mu, double[][] eigen, Matrix[] scaling, IntSet labels)```
Constructor.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static RDA` ```fit(double[][] x, int[] y, double alpha)```
Learn regularized discriminant analysis.
`static RDA` ```fit(double[][] x, int[] y, double alpha, double[] priori, double tol)```
Learn regularized discriminant analysis.
`static RDA` ```fit(double[][] x, int[] y, java.util.Properties prop)```
Learns regularized discriminant analysis.
`static RDA` ```fit(Formula formula, DataFrame data)```
Learns regularized discriminant analysis.
`static RDA` ```fit(Formula formula, DataFrame data, java.util.Properties prop)```
Learns regularized discriminant analysis.
• ### Methods inherited from class smile.classification.QDA

`fit, fit, predict, predict, priori`
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Methods inherited from interface smile.classification.Classifier

`applyAsDouble, applyAsInt, f, predict`
• ### Constructor Detail

• #### RDA

```public RDA(double[] priori,
double[][] mu,
double[][] eigen,
Matrix[] scaling)```
Constructor.
Parameters:
`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.
• #### RDA

```public RDA(double[] priori,
double[][] mu,
double[][] eigen,
Matrix[] scaling,
IntSet labels)```
Constructor.
Parameters:
`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 labels
• ### Method Detail

• #### fit

```public static RDA fit(Formula formula,
DataFrame data)```
Learns regularized discriminant analysis.
Parameters:
`formula` - a symbolic description of the model to be fitted.
`data` - the data frame of the explanatory and response variables.
• #### fit

```public static RDA fit(Formula formula,
DataFrame data,
java.util.Properties prop)```
Learns regularized discriminant analysis.
Parameters:
`formula` - a symbolic description of the model to be fitted.
`data` - the data frame of the explanatory and response variables.
• #### fit

```public static RDA fit(double[][] x,
int[] y,
java.util.Properties prop)```
Learns regularized discriminant analysis.
Parameters:
`x` - training samples.
`y` - training labels.
• #### fit

```public static RDA fit(double[][] x,
int[] y,
double alpha)```
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.
• #### fit

```public static RDA fit(double[][] x,
int[] y,
double alpha,
double[] priori,
double tol)```
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. 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.