Contents
Generative vs Discriminative Models/Chapter 08 of 10
08Side by side: generative versus discriminative
8.1The comparison
| Generative | Discriminative | |
|---|---|---|
| Learns | p(x,y)=p(y)\,p(x\mid y), or p(x) | p(y\mid x), or a map x\mapsto y |
| Classifies by | Bayes’ theorem, (2) | reading off p(y\mid x) |
| Fitting | joint likelihood; often counts and averages | conditional likelihood; numerical optimization |
| Small data | better (Ng and Jordan: O(\log n) examples) | worse (O(n) examples) |
| Large data | limited by its assumptions | usually more accurate |
| Can generate | yes | no |
| Missing features, outliers | marginalize; use p(x) | no principled answer |
| Classic examples | naive Bayes, Gaussian discriminant analysis (LDA, QDA), hidden Markov models | logistic regression, support vector machines, decision trees |
| Modern examples | GPT, diffusion models, flow matching, GANs, variational autoencoders | image classifiers, click-through prediction |
8.2Common misconceptions
- “Generative models are deep networks that make images and text.” Naive Bayes (1961) and linear discriminant analysis (1936) are generative models; GPT and diffusion models are just very large ones (Murphy, 2022, §9.4).
- “Linear discriminant analysis is a discriminative model.” Despite the name, it fits a Gaussian to each class and is generative (Murphy, 2022, §9.1).
- “Naive Bayes and logistic regression are the same model, since both are linear.” Same form \sigma(w^\top x+b), different objectives (9), different weights and different results (Example 4: 1.4\% against 0\% training error).
- “Discriminative models are always more accurate.” Only with enough data; with a handful of examples the generative model often wins (Figure 8), and with correct assumptions it is never worse.
- “A GAN is discriminative because it contains a discriminator.” The product is the generator, a generative model; the discriminator is a training signal, and at the optimum it is the Bayes posterior (20).
- “A generative model’s posterior detects outliers.” The posterior divides p(x) away; use p(x) (Example 6).
- “Flow matching paths are always straight.” The training lines (16) are straight; the learned flow is only nearly straight (Figure 7(b)), and a single step gives the data mean. Pairing noise with data without crossings makes it straight.