Quadratic Discriminant Analysis (QDA)

Machine Learning
Introduced by
Classical Gaussian discriminant analysis (Fisher / Welch lineage)
Year
1939
Type
Generative Gaussian classifier

What does it do?

Quadratic discriminant analysis is a generative classifier that models each class with its own multivariate Gaussian distribution, allowing each class a separate covariance matrix.

Unlike linear discriminant analysis, which assumes a shared covariance and yields linear boundaries, QDA's per-class covariances produce curved (quadratic) decision boundaries, letting it capture differences in the spread and orientation of the classes.

The intuition behind the method

Both LDA and QDA imagine each class as a cloud of points shaped like a Gaussian ellipsoid, and classify a new point by which cloud it most plausibly came from. LDA assumes every class cloud has the same shape and orientation, so only the centres differ and the dividing line is straight. QDA relaxes that: each class may have its own shape, size, and tilt. When one class is tight and another diffuse, or they are oriented differently, a straight boundary cannot separate them well, but the curved boundary QDA draws can. The price is that estimating a full covariance per class needs more data.

History

Quadratic discriminant analysis belongs to the Gaussian discrimination theory that builds on Fisher's linear discriminant and the Bayesian decision rule for normally distributed classes. It is obtained by dropping LDA's equal-covariance assumption. Both The Elements of Statistical Learning and An Introduction to Statistical Learning discuss QDA alongside LDA; James et al. (2013) present it in Section 4.4.4 as the extension of LDA that yields quadratic boundaries.

When to use it

Choose QDA over LDA when the classes appear to have genuinely different covariance structures, meaning different spreads or orientations, and when there is enough training data per class to estimate a full covariance matrix. Before relying on it, test whether the class covariance matrices are heterogeneous, for example with Box's M test, bearing in mind that this test is itself sensitive to departures from normality. Check each class for approximate normality and for outliers as well. If the covariance matrices do not differ significantly, a pooled covariance matrix, as in LDA, is the usual choice. Statistical software such as SAS DISCRIM applies the same logic, using the pooled matrix unless heterogeneity is significant. QDA suits problems with a moderate number of features and roughly Gaussian class distributions. Do not use it when features are many relative to the samples per class, because the per-class covariance estimates become unstable and QDA overfits; LDA, regularized discriminant analysis, or naive Bayes (which assumes diagonal covariance) are then safer choices. When variables are clearly non-normal or samples are small, nonparametric classification methods are the recommended alternative.

Limitations and considerations

  • Estimates a full covariance per class, requiring substantially more data than LDA.
  • Prone to overfitting when features are many or samples per class are few.
  • Assumes class-conditional normality and is sensitive to outliers, which distort the mean and covariance estimates.
  • Its quadratic boundaries are harder to interpret than the linear boundaries of LDA.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Allows each class its own covariance, so it can fit boundaries that a shared-covariance linear rule cannot.
  • As a generative model, it gives class posterior probabilities whose quality depends on how well the Gaussian assumption holds.
  • Can fit better than LDA when class covariances differ substantially and there is enough data to estimate them.
  • Parameters have closed-form maximum-likelihood estimates (sample means, covariances, and class frequencies), so fitting needs no iterative optimisation.

Applications

  • Classification problems where classes differ in spread or orientation, with ample data.
  • A flexible Gaussian baseline to compare against LDA and other classifiers.
  • Medical and biological discrimination where class covariances are expected to differ.
  • Pattern-recognition tasks with moderate dimensionality and roughly Gaussian features.
  • Teaching the bias-variance trade-off between linear (LDA) and quadratic (QDA) classifiers.

How it works

How it works

1

QDA assumes that, within each class k, the features follow a multivariate normal distribution with class-specific mean μₖ and class-specific covariance Σₖ. This per-class covariance is the defining difference from LDA, which forces a single shared Σ across all classes.

Formula
X \mid Y=k \ \sim\ \mathcal{N}(\mu_k, \Sigma_k)
2

By Bayes' rule, the posterior probability of a class is proportional to its Gaussian density times its prior. Taking logs gives a discriminant score for each class that includes a quadratic form in x with the class's own inverse covariance, plus log-determinant and prior terms. Because the quadratic term differs across classes, it does not cancel, which is why the boundaries are quadratic rather than linear.

Formula
\delta_k(x) = -\tfrac{1}{2}\ln|\Sigma_k| - \tfrac{1}{2}(x-\mu_k)^\top \Sigma_k^{-1}(x-\mu_k) + \ln \pi_k
3

A new observation is assigned to the class with the largest discriminant score, equivalently the highest posterior probability. The set of points where two classes tie out forms a quadratic surface, so QDA can carve curved regions in feature space.

Formula
\hat y = \arg\max_k\ \delta_k(x)
4

The parameters are estimated by maximum likelihood from the training data: each class mean is its sample mean, each class covariance is its sample covariance computed with the maximum-likelihood divisor (the class sample size), and each prior is the observed class frequency. Because these estimates are closed-form, fitting involves no iterative optimisation. Estimating a separate covariance per class is what gives QDA its flexibility and also its larger appetite for data. As a rough guide, a full covariance matrix for p features has p(p+1)/2 distinct entries, so each class needs enough observations to estimate all of them reliably; cross-validation is the practical way to compare QDA with LDA or regularized alternatives on the data at hand.

Formula
\hat\mu_k,\ \hat\Sigma_k,\ \hat\pi_k\ \text{from class samples (MLE)}

Common pitfalls

  • Using QDA with small per-class samples, where covariance estimates are unstable.
  • Applying it to high-dimensional data without regularization, which can produce singular covariance matrices.
  • Ignoring strong non-normality or outliers that violate the Gaussian assumption.
  • Defaulting to QDA when LDA's simpler shared-covariance model generalizes better.

Frequently asked questions

How does QDA differ from LDA?

Both model each class as a Gaussian, but LDA assumes all classes share one covariance matrix, giving linear boundaries, while QDA lets each class have its own covariance, giving quadratic boundaries. QDA is more flexible but estimates many more parameters, so it needs more data and can overfit where LDA would generalize better.

When is QDA likely to overfit?

When the number of features is large relative to the samples per class, because each class needs its own full covariance matrix, and the number of entries in that matrix grows with the square of the number of features. Unstable or near-singular covariance estimates lead to overfitting; regularized discriminant analysis, which shrinks toward a shared covariance, is a remedy.

Does QDA require normally distributed features?

It assumes class-conditional multivariate normality. Strong non-normality or outliers distort the estimated class means and covariances, and therefore the quadratic boundaries. Checking the class distributions or transforming features are common responses, and a different classifier may be preferable when normality is badly violated.

Related methods

Sources

  1. Hastie, T., Tibshirani, R., & Friedman, J. (2009). The Elements of Statistical Learning (2nd ed.). Springer.

    ISBN: 978-0-387-84857-0
  2. James, G., Witten, D., Hastie, T., & Tibshirani, R. (2013). An Introduction to Statistical Learning. Springer.

    ISBN: 978-1-4614-7138-7
  3. An Introduction to Statistical Learning, Section 4.4.4 Quadratic Discriminant Analysis, p. 149