Generative vs Discriminative Models
Learning the joint distribution P(x,y) versus learning the decision boundary P(y|x) directly
Learning the joint distribution P(x,y) versus learning the decision boundary P(y|x) directly
A generative model learns how the data is produced — the joint distribution P(x,y) — and can
therefore generate new samples and also classify by applying Bayes' theorem. A discriminative model
only learns the decision boundary P(y|x) between classes, which is usually easier and gives
better raw classification accuracy, but can't generate new data.
This distinction is the reason "generative AI" is called generative in the first place — the whole field is about models in the first bucket. It also shows up constantly in exam questions comparing Naive Bayes vs Logistic Regression, or GMM vs SVM, so the comparison table below is worth memorizing cold.
Simple shabdo mein: a discriminative model is like a student who only learns "which side of the line does this answer fall on" — great at getting the label right, but ask it to produce a new example of class A and it has no idea where to start, because it never modeled what class A data actually looks like. A generative model is like a student who actually learned how each class's data is generated — so it can both classify and generate new examples.
Formally: a discriminative model directly learns P(y|x) — the probability of a label given the
input — by learning a decision boundary. A generative model learns P(x|y) and P(y) for each
class, and gets P(y|x) only indirectly, via Bayes' theorem.
P(x|y) plus the class prior P(y).P(x|y) into P(y|x).x from the learned P(x|y) for the class you want.Discriminative approach skips steps 1 and 3 entirely — it directly fits a function (boundary) that
maps x → P(y|x), with no notion of how x itself is distributed.
Bayes' theorem
P(y|x) = P(x|y) P(y) / P(x), where P(x) = Σ_y P(x|y) P(y).
Here P(y|x) is the posterior (probability of label y given the observed input x), P(x|y) is
the likelihood (how likely this input is under class y's learned distribution), P(y) is the prior
(how common class y is overall), and P(x) is the evidence — the total probability of seeing x
across all classes, used purely to normalize.
Generative models learn the joint P(x,y) (via P(x|y) and P(y), then apply Bayes to get
P(y|x)); discriminative models learn P(y|x) directly, with no model of P(x) at all.
| Aspect | Generative | Discriminative |
|---|---|---|
| Learning objective | Model how data is generated | Model the decision boundary |
| Probability distribution | Joint P(x,y) (via P(x|y), P(y)) | Conditional P(y|x) directly |
| Training process | Estimate per-class distributions + priors | Directly optimize boundary/classifier parameters |
| Decision boundary | Derived indirectly via Bayes' theorem | Learned explicitly and directly |
| Data requirements | Needs enough data to model full distribution per class (more data-hungry) | Needs less data for comparable classification accuracy |
| Applications | Image/text/audio generation, anomaly detection, data augmentation | Spam filtering, image classification, sentiment analysis |
Consider a simple 2-class problem: classify a fruit as apple or orange using one feature, weight in grams. Say apples cluster around 150g and oranges around 200g (illustrative numbers).
P(weight | apple) centered
near 150g and another Gaussian P(weight | orange) centered near 200g, plus priors P(apple) and
P(orange) from the class frequencies in training data. To classify a new fruit of weight w, it
computes P(apple|w) and P(orange|w) via Bayes' theorem and picks the larger one. Bonus: it can
also sample a brand-new plausible weight from either Gaussian — that's the generative part.w, but it has no way to
generate a new plausible apple or orange weight — it never learned what either class's data
actually looks like, only where the line between them sits.Both can land on the same decision boundary here, but only the generative model can answer "give me a new apple-like weight."
P(x) is a normalizer only — discriminative models never need to compute it,
which is part of why they're often computationally simpler.P(x,y) vs P(y|x)) that defines the category, not the
architecture.Generative learns how data is made and classifies via Bayes' theorem; discriminative learns only the boundary between classes — that one distinction is why only generative models can create new samples.