Linear Discriminant Analysis is a generative model for classification. It is a generalization of Fisher’s linear discriminant. LDA works on continuous variables. If the classification task includes categorical variables, the equivalent technique is called the discriminant correspondence analysis.

The goal of Linear Discriminant Analysis is to project the features in higher dimension space onto a lower-dimensional space to both reduce the dimension of the problem and achieve classification.

## Key ideas

• Generative Model that tries to estimate $P (X = x \mid Y = 1)$ and $P (X = x \mid Y = -1)$
• Used for classification through dimension reduction
• Requires continuous variables
• Relies on normality assumption for $P(X \mid Y = 1)$ and $P(X \mid Y = 0)$
• Requires homoscedasticity and full rank covariances

## Concept

Consider a simple problem in which we want to decide whether a drug should be given to patients or not. Our features will be the gene expressions, and we will have 2 labels, for patients for which the drug worked, and for which it did not.

In PCA, we are interested in genes with the largest variations. In LDA, we are interested in maximizing the separability between the 2 known groups to make better decisions.

We’ll illustrate how we can improve the separability by this simple example. We suppose that we have 2 features, one for each gene. This means that we can plot the graph on a 2D plane.

How can we reduce the dimension of this problem to 1D ?

A bad way to approach this problem would be to project on the X-axis.

This would imply losing a lot of information from the Y-axis. what LDA does is that it projects the data onto a new axis in a way to maximize the separation between the 2 categories.

The projection, therefore, looks like this now, which is a good improvement :

How is this new axis created ?

• The new axis should maximize the distance between the two means :

• The new axis should minimize the variation, i.e scatter within each category

Both of the criteria can be optimized using the following ratio :

The numerator should ideally be large, and the numerator should be small. If we have 3 dimensions or more, the process remains the same!

If we have 3 categories, the process pretty much remains the same. We compute the distance to a central point and maximize the distance with respect to it.

The new criteria is now :

Another thing that changes when adding this class is that we do now project on a new place, not a single axis. This is because the 3 central points for each category define a plane. We can now build new X and Y axis, optimized for classification.

Being able to draw the data on 2 axes is interesting if we have an initial high dimensional problem. Once we redefined our X and Y axis, it is really easy to apply fit a linear regression on top! And voilà, this is the LDA!

## Theory

Back to our example with 2 classes. We would like to find the two underlying marginal distributions.

We’ll define the distributions of the 2 classes :

• $G = L(X \mid Y=1)$ distribution of the class 1
• $H = L(X \mid Y=-1)$ distribution of the class -1

We can plot the probability densities :

The LDA relies on some strong hypothesis which we’ll explicit now.

where :

### Homoscedasticity

LDA should be used when the covariance matrices are equal among the 2 classes :

## Learning process

To understand the intuition behind how LDA works, we can define a likelihood ratio :

Using Bayes’ theorem :

We can re-define $P(Y=1)$ as $p$ and $P(Y=1 \mid X = x)$ as the prior probability $\eta(x)$.

We can easily isolate the prior probability $\eta(x)$ :

## Computation

How do we find the parameters of the model? How does the learning process work?

If $\eta(x) > \frac {1} {2}$, then $\phi(x) ≥ \frac {1-p} {p}$ . This means that :

Which can be re-written as :

Where :

This should remind you of the ratio to optimize we defined in the first part of the article! The parameter $\alpha$ and $\beta$ are the parameters of the linear regression fitted on the modified axis plane.

## Parameter estimation

The question now becomes : How can we estimate $\alpha$ and $\beta$ ? By Maximum Likelihood, we obtain the following :

We then simply replace those values to find $\hat{\alpha}$ and $\hat{\beta}$.

So far, we supposed that the class variance had to be the same : $\sigma_+ = \sigma_- = \sigma$. If we relax this hypothesis, we obtain the QDA, where $\sigma_+ ≠ \sigma_-$.