On Discriminative vs. Generative Classifiers: A comparison of logistic regression and naive Bayes

Andrew Y. Ng, Michael I. JordanNeurIPS 2001

This classic 2001 paper by Andrew Ng and Michael Jordan is a cornerstone of machine learning theory. It challenges the "folk wisdom" that discriminative models are always superior to generative ones by demonstrating that the "best" model depends entirely on the size of the training dataset.

While discriminative classifiers (like Logistic Regression) eventually outperform generative ones (like Naive Bayes) as data grows, generative models often reach their peak performance much faster. Specifically, Naive Bayes needs only $O(\log n)$ samples to converge, while Logistic Regression requires $O(n)$, creating two distinct regimes of performance based on training set size.

The "Discriminative is Always Better" Dogma

In the early 2000s, the prevailing consensus—championed by theorists like Vladimir Vapnik—was that one should always solve a classification problem "directly" (discriminatively) rather than solving a more general problem (generative modeling) as an intermediate step. The logic was simple: why waste effort modeling the distribution of the inputs $p(x)$ if you only care about the labels $p(y|x)$?

Ng and Jordan set out to investigate whether this mantra holds true in practice, specifically looking at sample complexity: how many training examples ($m$) are needed before a model reaches its best possible performance (asymptotic error)?

Comparing Generative and Discriminative Pairs

The authors compare a specific Generative-Discriminative pair:

  1. Naive Bayes (Generative): Models the joint probability $p(x, y)$ by assuming features are independent given the label.
  2. Logistic Regression (Discriminative): Models the conditional probability $p(y|x)$ directly.

They use theoretical analysis (VC dimension and uniform convergence bounds) to prove the rates at which these models approach their asymptotic errors. They then validate these theories by plotting "learning curves"—graphs of generalization error versus the number of training examples—across 15 different datasets from the UCI Machine Learning repository (split into continuous and discrete inputs).

Key Insights: The Two Regimes of Learning

The paper identifies two distinct stages of learning, revealing a trade-off between asymptotic error and convergence rate:

  • Logistic Regression has a lower asymptotic error because it can represent more complex decision boundaries, but it converges slowly.
  • Naive Bayes has a higher asymptotic error due to its restrictive independence assumption, but it boasts a much faster convergence rate.

The most striking theoretical finding is the gap in sample complexity. For $n$ dimensions, Naive Bayes only needs $O(\log n)$ samples to converge to its best performance, whereas Logistic Regression needs $O(n)$ samples. As the number of features grows, the "data advantage" of Naive Bayes becomes even more pronounced.

Empirical Confirmation of the Crossover

The authors proved that while Logistic Regression is asymptotically better, Naive Bayes reaches its (higher) ceiling much faster. The experimental plots show a clear "crossover" in many datasets.

Learning curves showing the crossover between Naive Bayes and Logistic Regression

As seen in the learning curves above, on datasets like adult and lymphography, the generative model starts with significantly lower error. However, the discriminative model eventually overtakes it as the number of samples $m$ increases. In several experiments with small total sample sizes, Logistic Regression never actually catches up to Naive Bayes, illustrating that for "small data" problems, the generative approach is often practically superior.

Limitations and Future Directions

  • The Independence Assumption: The fast convergence of Naive Bayes relies on the features being somewhat informative. If the "Naive Bayes assumption" is wildly incorrect for a specific dataset, the generative model's asymptotic error might be too high to be useful, even with its fast convergence.
  • Regularization: The paper focuses on "pure" versions of these algorithms. Modern techniques like $L_1$ or $L_2$ regularization can help discriminative models perform better with less data, which is a separate but related axis of optimization.
  • Hybrid Models: The authors suggest that a logical next step is designing hybrid classifiers that attempt to combine the "fast start" of generative models with the "high ceiling" of discriminative ones.

Summary updated

BibTeX
@inproceedings{ng2001discriminative,
  author = {Andrew Y. Ng and Michael I. Jordan},
  title = {{On Discriminative vs. Generative Classifiers: A comparison of logistic regression and naive Bayes}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2001},
}
Figure