Generative vs Discriminative Models

Learn the boundary between classes, or learn what each class looks like?

🟡 intermediate4 min readtheory
These are two ways of building a classifier. A discriminative model learns the boundary between classes directly: given these features, which class is it? Logistic regression, SVMs and BERT classifiers work this way, and they are usually more accurate when all you need is to classify. A generative model learns what each class looks like, meaning how its data is produced, and uses that to classify. Naive Bayes, GANs and GPT are generative, which is why they can also create brand-new examples.

The Fundamental Probabilistic Split

Every probabilistic machine learning model operates on inputs XX and labels YY.

The key distinction is how the model models the probability distributions:

┌──────────────────────────┬──────────────────────────┐
│ 1. DISCRIMINATIVE MODELS │ 2. GENERATIVE MODELS     │
├──────────────────────────┼──────────────────────────┤
│ Estimates P(Y | X).      │ Estimates P(X, Y) =      │
│ Learns DECISION BOUNDARY │ P(X | Y) * P(Y).         │
│ separating classes.      │ Learns HOW DATA IS MADE  │
│ Cannot generate data!    │ for each class.          │
│ Logistic Regression, SVM │ Naive Bayes, VAEs, GANs  │
└──────────────────────────┴──────────────────────────┘

1. Discriminative Models: "Where is the boundary?"

Discriminative models model the conditional probability P(Y∣X)P(Y \mid X) directly.

They do not care how features XX were generated or what individual classes look like in isolation. They care only about drawing a boundary that separates Class 0 from Class 1.

  Discriminative Perception:
  "I don't know what makes a cat a cat. All I know is that if a picture has triangular ears and whiskers, it is 99% likely to be a cat rather than a dog!"

2. Generative Models: "How was this data generated?"

Generative models model the joint probability distribution P(X,Y)P(X, Y).

Using Bayes' Rule, they model the likelihood of observing features XX given class YY (P(X∣Y)P(X \mid Y)) alongside class prior P(Y)P(Y):

P(Y∣X)=P(X∣Y)P(Y)P(X)P(Y \mid X) = \frac{P(X \mid Y) P(Y)}{P(X)}
  Generative Perception:
  "I have learned a detailed statistical template for what a Cat looks like P(X | Cat) and what a Dog looks like P(X | Dog). To classify a new image, I compare which template matches better!"

Classical Pairing: Naive Bayes vs Logistic Regression

FeatureNaive Bayes (Generative)Logistic Regression (Discriminative)
Probability FormModels P(X∣Y)P(Y)P(X \mid Y) P(Y)Models P(Y∣X)P(Y \mid X) directly
Feature IndependenceAssumes features XiX_i are independentNo feature independence assumption
Small Data BehaviorConverges faster with small datasetsRequires more data to reach asymptotic performance
Asymptotic AccuracyLower asymptotic accuracy limitHigher asymptotic accuracy limit

Say this out loud

Discriminative models estimate conditional probability P(Y | X) directly, learning decision boundaries to separate classes. Generative models estimate joint probability P(X,Y) = P(X | Y) P(Y), modeling how data features are generated for each class. Discriminative models excel at classification, while Generative models can synthesize brand new data points.

Followups to expect

  1. Is GPT a Generative or Discriminative model? GPT is a Generative model. It models the joint distribution of sequence tokens P(X1,X2,…,XN)P(X_1, X_2, \dots, X_N), allowing it to sample new synthetic text tokens step by step.
  2. Why does Logistic Regression outperform Naive Bayes on large datasets? Ng & Jordan (2001) proved that Naive Bayes reaches its asymptotic error threshold faster with less data, but Logistic Regression achieves a lower final error rate as dataset size approaches infinity.

Check yourself

Question 1 of 3

What probability distribution do Discriminative Models estimate directly when classifying input features X into target labels Y?

More in Classical ML

See all →
Bias–Variance Tradeoff4 minOverfitting vs Underfitting3 minLinear Regression4 min