Skip to content
StackDecode
AI & ML Atlas
Machine LearningalgorithmAnimated walkthrough

Linear Discriminant Analysis for Dimensionality Reduction

Projects labelled data onto the axes that best separate the classes.

The idea

Where PCA looks for maximum variance, LDA uses the labels: it chooses directions that make class means far apart while keeping each class tight. At most (classes − 1) useful directions exist. It is supervised dimensionality reduction.

maximise (wᵀS_b w) / (wᵀS_w w)

Watch it run

The pipeline lights up one step at a time. Use the controls to pause or step through it.

  1. 1Compute the mean of each class and of all data.
  2. 2Compute the between-class and within-class scatter.
  3. 3Find the eigenvectors of S_w⁻¹S_b.
  4. 4Project onto the top eigenvectors.

maximise (wᵀS_b w) / (wᵀS_w w)

1/4

Step by step

  1. 1Compute the mean of each class and of all data.
  2. 2Compute the between-class and within-class scatter.
  3. 3Find the eigenvectors of S_w⁻¹S_b.
  4. 4Project onto the top eigenvectors.

Where it is used

Pre-processing for classifiers and 2-D class visualisation.

Watch out for

Assumes roughly Gaussian classes with similar covariance.

Related