Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Scikit learn Scikit learn Discriminant Analysis

From Leeroopedia


Knowledge Sources
Domains Supervised Learning, Dimensionality Reduction
Last Updated 2026-02-08 15:00 GMT

Overview

Discriminant analysis methods classify observations by modeling the distribution of features within each class, using these distributions to derive optimal decision boundaries.

Description

Discriminant analysis encompasses generative classification methods that model the class-conditional distributions of features and apply Bayes' theorem to obtain posterior class probabilities. Linear Discriminant Analysis (LDA) assumes all classes share a common covariance matrix, yielding linear decision boundaries; Quadratic Discriminant Analysis (QDA) allows each class its own covariance matrix, producing quadratic boundaries. Beyond classification, LDA also serves as a supervised dimensionality reduction technique by projecting data onto the most discriminative directions. These methods bridge statistical modeling and classification, providing both predictive capability and geometric insight into class structure.

Usage

Use Linear Discriminant Analysis when classes are approximately Gaussian with similar covariance structures, when you need a linear classifier with probabilistic outputs, or when supervised dimensionality reduction is desired (projecting to at most C1 dimensions for C classes). Use Quadratic Discriminant Analysis when classes have different covariance structures and the dataset is large enough to estimate per-class covariance matrices reliably. LDA is particularly useful as a preprocessing step for visualization or before applying classifiers that benefit from reduced dimensionality.

Theoretical Basis

Generative Model: Both LDA and QDA assume class-conditional Gaussian distributions:

p(x|y=c)=𝒩(x|μc,Σc)

Using Bayes' theorem:

p(y=c|x)=p(x|y=c)p(y=c)p(x)

The predicted class is y^=argmaxcp(y=c|x).

Linear Discriminant Analysis (LDA) assumes a shared covariance: Σc=Σ for all classes. The log-posterior simplifies to a linear function of x:

δc(x)=xTΣ1μc12μcTΣ1μc+logπc

where πc=p(y=c) is the prior probability. The decision boundary between classes c and c is the set where δc(x)=δc(x), which is a hyperplane.

LDA for dimensionality reduction finds projections that maximize the ratio of between-class scatter to within-class scatter:

w*=argmaxwwTSBwwTSWw

where: SB=c=1Cnc(μcμ)(μcμ)T (between-class scatter) SW=c=1Cic(xiμc)(xiμc)T (within-class scatter)

The solution is obtained from the generalized eigenvalue problem SBw=λSWw. At most C1 non-zero eigenvalues exist, limiting the reduced dimensionality to C1.

Quadratic Discriminant Analysis (QDA) allows per-class covariance matrices Σc. The log-posterior includes a quadratic term in x:

δc(x)=12(xμc)TΣc1(xμc)12log|Σc|+logπc

This produces quadratic (curved) decision boundaries, providing more flexibility at the cost of estimating more parameters.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment