Generative vs Discriminative Models
A discriminative model learns only the boundary between classes; a generative model learns how each class's data was produced in the first place — the difference between memorizing where the line is and understanding what's on each side of it.
Prerequisites: Logistic Regression, Bayesian Inference
Ask two different people to sort a pile of photographs into "cats" and "dogs." One studies thousands of labeled examples and learns a rule purely about the boundary — pointy ears plus whiskers plus small size tends to fall on the cat side, everything else on the dog side. Ask them to draw a brand-new cat from imagination and they can't; they've never learned what a cat actually looks like as a whole, only how to tell it apart from a dog. The other person studies the same photographs but tries to internalize what a typical cat looks like and, separately, what a typical dog looks like — the full appearance, not just the distinguishing features. Ask them to sort a new photo and they compare it against both mental templates; ask them to draw a new cat and, in principle, they can, because they've actually modeled what a cat is, not merely where the dividing line falls. These are, respectively, a discriminative and a generative approach to the same classification task.
The mechanism: two different quantities to learn
Every classification problem has an input (the photo, the set of features) and a label (cat or dog). A discriminative model learns directly — given this specific , what's the probability of each label? — without ever modeling how itself was generated. Logistic regression is the standard example: it learns a decision boundary through feature space and stops there.
A generative model instead learns for each class — what does a typical cat's feature vector look like, what does a typical dog's look like — plus the base rates , how common each class is overall. Classification then happens indirectly, via Bayes' rule:
Here (called the likelihood) says how plausible this particular is under class 's learned template, (the prior) says how common class is before seeing any features at all, and is a normalizing constant — the total probability of seeing this under any class, ensuring the result is a valid probability. In words: a generative model doesn't jump straight to "which class"; it separately asks "how well does each class's template explain this data" and "how common is each class to begin with," then combines the two.
The crucial extra thing a generative model buys, beyond classification, is the ability to sample — because it has modeled , the full shape of each class's data, it can draw new, synthetic examples from that shape. A discriminative model has no such capability; it has never modeled 's distribution at all, only the boundary that separates labels within it.
The decision-boundary explorer below lets you see how a classifier's dividing line adapts to the underlying data; picture the discriminative approach as fitting that line directly, and the generative approach as first fitting a cloud shape to each class and only then reading the boundary off where the two clouds cross.
Worked example 1: computing from a generative model
Suppose a simple 1-feature model of daily return for "trending day" () versus "choppy day" () has learned and for a specific observed value , with base rates and (trending days are less common). Applying Bayes' rule:
Despite trending days being the rarer class overall (only 40% base rate), this specific return value is so much more likely under the trending template ( vs ) that the posterior probability swings heavily toward "trending," landing at . A discriminative model given only this same would produce a similar final probability, but it would have arrived there by fitting a boundary directly, never separately quantifying "how typical is this for each class" or "how common is each class."
Worked example 2: why the generative route can also produce new samples
Using the same fitted class templates, suppose is a normal distribution centered at with standard deviation . A generative model can draw a brand-new synthetic "trending day" return by sampling from — for instance drawing standard deviations above the mean gives a synthetic sample of , a plausible new trending-day return that was never in the training data. A discriminative logistic regression, having only ever learned the boundary between the two classes, has no analogous "draw a new example of class 1" operation available at all — it was never given a distribution to sample from.
A discriminative model learns directly and only ever answers "which class." A generative model learns for each class plus the base rates , uses Bayes' rule to answer the same classification question, and additionally gains the ability to sample new, synthetic data from each class's learned distribution.
What this means in practice
Discriminative models are usually the better choice when classification accuracy is the only goal and there's plenty of labeled data, because they spend their entire learning capacity on the boundary that actually matters for the task, rather than on the harder job of modeling the full shape of each class's data. Generative models earn their extra complexity when you also need to handle missing features gracefully (a well-specified can marginalize over what's missing), need to detect out-of-distribution inputs (data that fits neither class's template well is flagged as unusual, something a discriminative boundary can't naturally express), or need to generate synthetic data, as in synthetic scenario generation.
It's a common mix-up to think "generative" means "produces text or images," conflating it with modern large language models specifically. The generative-versus-discriminative distinction is much older and purely about what probability is being modeled — or versus — and applies just as much to a simple naive Bayes spam filter as to a large diffusion model. A naive Bayes classifier is fully generative in this technical sense even though nobody would describe spam filtering as "AI-generated content."
Practice
- A generative model gives , , with priors , . Compute using Bayes' rule.
- Why can a generative model handle a missing feature more gracefully than a purely discriminative one, in terms of what each has actually learned?
- Give one concrete reason a quant might prefer a discriminative model for a pure "will this trade be profitable, yes or no" classifier, even knowing a generative model would also let them sample synthetic trades.
Related concepts
Practice in interviews
Further reading
- Ng & Jordan, On Discriminative vs. Generative Classifiers (2001)
- Bishop, Pattern Recognition and Machine Learning, ch. 4