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

A. NgMichael I. Jordan

article2001NeurIPS2,660 citations

Demonstrates that while discriminative classifiers achieve lower asymptotic error, generative models require only logarithmic sample complexity to approach their asymptotic performance, explaining why naive Bayes frequently outperforms logistic regression on smaller training sets.

Listen

The article addresses the common view that discriminative classifiers such as logistic regression should almost always be preferred to generative ones such as naive Bayes, along with the related belief that the number of training examples needed grows linearly with the number of model parameters. These assumptions matter because many practical classification tasks involve limited data, and choosing the wrong approach can lead to unnecessarily high error rates.

The article set out to compare a generative-discriminative pair of classifiers both theoretically and empirically, focusing on how their error rates behave as the training set size increases.

The authors performed a theoretical analysis of convergence rates for naive Bayes and logistic regression under standard assumptions, then tested the predictions on fifteen datasets from the UCI repository using repeated random train-test splits.

The analysis shows that logistic regression reaches a lower asymptotic error rate, yet naive Bayes approaches its (higher) asymptotic error after only a logarithmic number of examples rather than a linear number. Experiments confirm two distinct performance regimes: with small training sets naive Bayes often yields lower error, while with larger sets logistic regression overtakes it; the crossover occurs at modest sizes in most datasets.

These results indicate that the preferred algorithm depends on available data volume, so practitioners can achieve better accuracy by matching the method to the scale of the problem rather than defaulting to one family. They also suggest that hybrid methods could combine the fast initial improvement of generative models with the superior final accuracy of discriminative ones.

The main limitations are that the analysis applies to specific generative-discriminative pairs and assumes a sufficient fraction of relevant features; results on very small or linearly separable datasets were sometimes inconclusive. The findings rest on both theory and consistent experimental patterns, supporting moderate-to-high confidence for the regimes described.

Ng et al (2001).pdf
Cover for On Discriminative vs. Generative Classifiers: A comparison of logistic regression and naive Bayes

Abstract

We compare discriminative and generative learning as typified by logistic regression and naive Bayes. We show, contrary to a widely-held belief that discriminative classifiers are almost always to be preferred, that there can often be two distinct regimes of performance as the training set size is increased, one in which each algorithm does better. This stems from the observationwhich is borne out in repeated experimentsthat while discriminative learning has lower asymptotic error, a generative classifier may also approach its (higher) asymptotic error much faster.

Table of Contents

  • 1 Introduction
  • 2 Preliminaries
  • 3 Analysis of algorithms
  • 4 Experiments
  • 5 Discussion
  • Acknowledgments
  • References

Knowls

  1. Knowl 1 — Two-Regime Performance Phenomenon of Generative vs. Discriminative Learning

    theoretical result

    When comparing a generative classifier (such as Naive Bayes) and its discriminative counterpart (such as logistic regression) on an nn-dimensional classification problem as the training set size mm increases, their relative generalization performance exhibits two distinct regimes:

    1. Small-sample regime (m=O(logn)m = O(\log n) to mnm \ll n): The generative classifier approaches its asymptotic generalization error ϵ(hGen,)\epsilon(h_{\text{Gen},\infty}) rapidly, requiring only O(logn)O(\log n) training examples. Because the discriminative classifier requires Ω(n)\Omega(n) examples to approach its asymptotic error, the generative model often achieves lower classification error in this regime: ϵ(hGen)<ϵ(hDis)\epsilon(h_{\text{Gen}}) < \epsilon(h_{\text{Dis}}).

    2. Large-sample regime (m=Ω(n)m = \Omega(n)): As the sample size grows, the discriminative classifier approaches its own asymptotic generalization error ϵ(hDis,)\epsilon(h_{\text{Dis},\infty}). Because discriminative training directly optimizes conditional likelihood or classification error over the linear hypothesis class, its asymptotic error is provably lower than or equal to that of the generative model: ϵ(hDis,)ϵ(hGen,)\epsilon(h_{\text{Dis},\infty}) \le \epsilon(h_{\text{Gen},\infty}). Consequently, the discriminative classifier catches up to and overtakes the generative classifier as mm \to \infty.

  2. Knowl 2 — Logarithmic Sample Complexity of Naive Bayes Generalization Error

    theoretical result

    Let hGenh_{\text{Gen}} be the Naive Bayes classifier trained on mm i.i.d. samples from distribution D\mathcal{D} over input space X\mathcal{X} and binary labels Y={T,F}\mathcal{Y} = \{T, F\}, and let hGen,h_{\text{Gen},\infty} be its population limit. Let ϵ(h)=Pr(x,y)D[h(x)y]\epsilon(h) = \Pr_{(x,y)\sim\mathcal{D}}[h(x) \ne y] denote the 0-1 generalization error.

    Define the margin proximity probability: G(τ)=Pr(x,y)D[(lGen,(x)[0,τn]y=T)(lGen,(x)[τn,0]y=F)]G(\tau) = \Pr_{(x,y)\sim\mathcal{D}}\left[\left(l_{\text{Gen},\infty}(x) \in [0, \tau n] \wedge y=T\right) \vee \left(l_{\text{Gen},\infty}(x) \in [-\tau n, 0] \wedge y=F\right)\right] where lGen,(x)=log(p(y=T)i=1np(xiy=T)p(y=F)i=1np(xiy=F))l_{\text{Gen},\infty}(x) = \log\left(\frac{p(y=T)\prod_{i=1}^n p(x_i \mid y=T)}{p(y=F)\prod_{i=1}^n p(x_i \mid y=F)}\right) is the population log-odds discriminant function.

    If G(τ)ϵ0/2+F(τ)G(\tau) \le \epsilon_0/2 + F(\tau) for some fixed constant ϵ0>0\epsilon_0 > 0 and function F(τ)F(\tau) independent of nn satisfying F(τ)0F(\tau) \to 0 as τ0\tau \to 0, then to guarantee that: ϵ(hGen)ϵ(hGen,)+ϵ0\epsilon(h_{\text{Gen}}) \le \epsilon(h_{\text{Gen},\infty}) + \epsilon_0 holds with high probability, it suffices that the training set size satisfies: m=Ω(logn)m = \Omega(\log n)

    Sufficient conditions for G(τ)G(\tau) to satisfy this bound include:

    • Conditional independence: If the Naive Bayes conditional independence assumption holds given yy and an Ω(1)\Omega(1) fraction of features are informative (with expected margin E[lGen,(x)y=T]=αn\mathbb{E}[l_{\text{Gen},\infty}(x) \mid y=T] = \alpha n for α>0\alpha > 0), Chernoff bounds yield G(τ)exp(O((ατ)2n))G(\tau) \le \exp(-O((\alpha - \tau)^2 n)), which is exponentially small in nn.
    • Bounded variance: If Var(lGen,(x))=O(n2η)\operatorname{Var}(l_{\text{Gen},\infty}(x)) = O(n^{2-\eta}) for some η>0\eta > 0, Chebyshev's inequality gives G(τ)O(1/((ατ)2nη))G(\tau) \le O(1 / ((\alpha - \tau)^2 n^\eta)), which vanishes for large nn.
  3. Knowl 3 — Sample Complexity Bound for Logistic Regression

    theoretical result

    Let H\mathcal{H} be the hypothesis class of all linear classifiers mapping an nn-dimensional input space X\mathcal{X} to binary labels Y={T,F}\mathcal{Y} = \{T, F\}, which has VC dimension nn. Let hDish_{\text{Dis}} be the linear classifier obtained by discriminative logistic regression on mm i.i.d. training examples drawn from distribution D\mathcal{D}, and let hDis,h_{\text{Dis},\infty} be its population (asymptotic) version.

    Uniform convergence bounds guarantee that with high probability over the sample draw: ϵ(hDis)ϵ(hDis,)+O(nmlogmn)\epsilon(h_{\text{Dis}}) \le \epsilon(h_{\text{Dis},\infty}) + O\left(\sqrt{\frac{n}{m}\log \frac{m}{n}}\right) where ϵ(h)=Pr(x,y)D[h(x)y]\epsilon(h) = \Pr_{(x,y)\sim\mathcal{D}}[h(x) \ne y] is the 0-1 generalization error.

    Consequently, for any fixed constant ϵ0>0\epsilon_0 > 0, guaranteeing ϵ(hDis)ϵ(hDis,)+ϵ0\epsilon(h_{\text{Dis}}) \le \epsilon(h_{\text{Dis},\infty}) + \epsilon_0 with high probability requires a sample complexity of: m=Ω(n)m = \Omega(n) which scales linearly with the number of dimensions/parameters nn.

  4. Knowl 4 — Asymptotic Error Superiority of Discriminative Classifiers

    theoretical result

    Let hGenh_{\text{Gen}} and hDish_{\text{Dis}} be any generative-discriminative pair of classifiers over input space X\mathcal{X} and label space Y={T,F}\mathcal{Y} = \{T, F\}, trained on distribution D\mathcal{D} over X×Y\mathcal{X} \times \mathcal{Y}. Let hGen,h_{\text{Gen},\infty} and hDis,h_{\text{Dis},\infty} denote their respective population (asymptotic) limits obtained as the number of training samples mm \to \infty.

    Assuming the hypothesis class H\mathcal{H} of discriminative classifiers (the class of linear classifiers for logistic regression) has finite VC dimension, the 0-1 generalization error ϵ(h)=Pr(x,y)D[h(x)y]\epsilon(h) = \Pr_{(x,y)\sim\mathcal{D}}[h(x) \ne y] satisfies: ϵ(hDis,)ϵ(hGen,)\epsilon(h_{\text{Dis},\infty}) \le \epsilon(h_{\text{Gen},\infty})

    This holds because the population discriminative classifier hDis,h_{\text{Dis},\infty} converges to infhHϵ(h)\inf_{h \in \mathcal{H}} \epsilon(h), making it asymptotically optimal within H\mathcal{H}, whereas the generative model hGen,h_{\text{Gen},\infty} optimizes joint data likelihood and selects a specific linear classifier that is not guaranteed to minimize classification error.

  5. Knowl 5 — Generalization Error Bound for Naive Bayes via Discriminant Margin

    theoretical result

    Let hGenh_{\text{Gen}} be a Naive Bayes classifier trained on mm i.i.d. samples from distribution D\mathcal{D} on X×{T,F}\mathcal{X} \times \{T, F\}, which predicts TT if and only if its empirical log-odds discriminant function lGen(x)>0l_{\text{Gen}}(x) > 0. Let lGen,(x)l_{\text{Gen},\infty}(x) and hGen,h_{\text{Gen},\infty} be the corresponding population discriminant function and classifier.

    Define the margin proximity function: G(τ)=Pr(x,y)D[(lGen,(x)[0,τn]y=T)(lGen,(x)[τn,0]y=F)]G(\tau) = \Pr_{(x,y)\sim\mathcal{D}}\left[\left(l_{\text{Gen},\infty}(x) \in [0, \tau n] \wedge y = T\right) \vee \left(l_{\text{Gen},\infty}(x) \in [-\tau n, 0] \wedge y = F\right)\right]

    Assume that class priors satisfy p0p(y=T)1p0p_0 \le p(y=T) \le 1-p_0 for some constant p0>0p_0 > 0, and that either:

    1. p0p(xi=1y=b)1p0p_0 \le p(x_i=1 \mid y=b) \le 1-p_0 for all features i{1,,n}i \in \{1,\dots,n\} and classes b{T,F}b \in \{T, F\} (for discrete binary inputs X={0,1}n\mathcal{X} = \{0,1\}^n), or
    2. σi2=Ey[Var(xiy)]p0\sigma_i^2 = \mathbb{E}_y[\operatorname{Var}(x_i \mid y)] \ge p_0 for all features ii (for continuous inputs X=[0,1]n\mathcal{X} = [0,1]^n).

    Then with high probability over the draw of mm training samples: ϵ(hGen)ϵ(hGen,)+G(O(lognm))\epsilon(h_{\text{Gen}}) \le \epsilon(h_{\text{Gen},\infty}) + G\left(O\left(\sqrt{\frac{\log n}{m}}\right)\right) where ϵ(h)=Pr(x,y)D[h(x)y]\epsilon(h) = \Pr_{(x,y)\sim\mathcal{D}}[h(x) \ne y].

  6. Knowl 6 — Uniform Parameter Convergence of Naive Bayes in Logarithmic Samples

    theoretical result

    Let D\mathcal{D} be a joint distribution over X×{T,F}\mathcal{X} \times \{T, F\} satisfying p0p(y=T)1p0p_0 \le p(y = T) \le 1 - p_0 for a fixed constant p0>0p_0 > 0. Let ϵ1>0\epsilon_1 > 0, δ>0\delta > 0, and Laplace smoothing parameter l0l \ge 0 be fixed. If the training sample size satisfies m=O(1ϵ12lognδ)m = O\left(\frac{1}{\epsilon_1^2} \log \frac{n}{\delta}\right), then with probability at least 1δ1 - \delta over mm i.i.d. training examples:

    1. Discrete inputs (X={0,1}n\mathcal{X} = \{0, 1\}^n): The empirical smoothed probability estimates p^\hat{p} satisfy: p^(xi=1y=b)p(xi=1y=b)ϵ1andp^(y=b)p(y=b)ϵ1|\hat{p}(x_i = 1 \mid y = b) - p(x_i = 1 \mid y = b)| \le \epsilon_1 \quad \text{and} \quad |\hat{p}(y = b) - p(y = b)| \le \epsilon_1 for all i{1,,n}i \in \{1, \dots, n\} and b{T,F}b \in \{T, F\}.

    2. Continuous inputs (X=[0,1]n\mathcal{X} = [0, 1]^n): The empirical means μ^iy=b\hat{\mu}_{i|y=b} and pooled variances σ^i2\hat{\sigma}_i^2 satisfy: μ^iy=bμiy=bϵ1,σ^i2σi2ϵ1,andp^(y=b)p(y=b)ϵ1|\hat{\mu}_{i|y=b} - \mu_{i|y=b}| \le \epsilon_1, \quad |\hat{\sigma}_i^2 - \sigma_i^2| \le \epsilon_1, \quad \text{and} \quad |\hat{p}(y = b) - p(y = b)| \le \epsilon_1 for all i{1,,n}i \in \{1, \dots, n\} and b{T,F}b \in \{T, F\}, where μiy=b=E[xiy=b]\mu_{i|y=b} = \mathbb{E}[x_i \mid y = b] and σi2=Ey[Var(xiy)]\sigma_i^2 = \mathbb{E}_y[\operatorname{Var}(x_i \mid y)].

    Thus, all O(n)O(n) parameters of Naive Bayes converge uniformly to their true population values with m=O(logn)m = O(\log n) training examples.

  7. Knowl 7 — Linear Scaling of the Naive Bayes Population Discriminant

    theoretical result

    In an nn-dimensional binary classification task with labels y{T,F}y \in \{T, F\}, suppose there exists a fixed constant γ>0\gamma > 0 such that for at least an Ω(1)\Omega(1) fraction of features i{1,,n}i \in \{1, \dots, n\}, the class-conditional distributions are separated: p(xi=1y=T)p(xi=1y=F)γ|p(x_i = 1 \mid y = T) - p(x_i = 1 \mid y = F)| \ge \gamma for discrete inputs X={0,1}n\mathcal{X} = \{0, 1\}^n, or μiy=Tμiy=Fγ|\mu_{i|y=T} - \mu_{i|y=F}| \ge \gamma for continuous inputs X=[0,1]n\mathcal{X} = [0, 1]^n, where μiy=b=E[xiy=b]\mu_{i|y=b} = \mathbb{E}[x_i \mid y = b].

    Then the expected value of the population Naive Bayes log-odds discriminant function: lGen,(x)=i=1nlogp(xiy=T)p(xiy=F)+logp(y=T)p(y=F)l_{\text{Gen},\infty}(x) = \sum_{i=1}^n \log \frac{p(x_i \mid y = T)}{p(x_i \mid y = F)} + \log \frac{p(y = T)}{p(y = F)} scales linearly with the feature dimension nn: E[lGen,(x)y=T]=Ω(n)andE[lGen,(x)y=F]=Ω(n)\mathbb{E}[l_{\text{Gen},\infty}(x) \mid y = T] = \Omega(n) \quad \text{and} \quad -\mathbb{E}[l_{\text{Gen},\infty}(x) \mid y = F] = \Omega(n)

    This linear growth occurs because each term in the sum has non-negative expectation due to the non-negativity of Kullback-Leibler divergence, and an Ω(1)\Omega(1) fraction of the terms have expectations strictly bounded away from zero by γ\gamma.

  8. Knowl 8 — Generative-Discriminative Classifier Pairs

    definition

    A Generative-Discriminative pair consists of two classification algorithms, hGenh_{\text{Gen}} and hDish_{\text{Dis}}, that share the same parametric model family for p(x,y)p(x, y) or p(yx)p(y \mid x), but are fitted using different optimization objectives:

    1. Generative classifier (hGenh_{\text{Gen}}): Fits model parameters by optimizing the joint likelihood of the inputs and labels on training set S={(x(i),y(i))}i=1mS = \{(x^{(i)}, y^{(i)})\}_{i=1}^m: maxi=1mlogp(x(i),y(i))\max \sum_{i=1}^m \log p(x^{(i)}, y^{(i)}) and classifies a new input xx via Bayes' rule: hGen(x)=argmaxyp(yx)=argmaxyp(xy)p(y)h_{\text{Gen}}(x) = \arg\max_y p(y \mid x) = \arg\max_y p(x \mid y)p(y).

    2. Discriminative classifier (hDish_{\text{Dis}}): Fits model parameters by maximizing the conditional likelihood: maxi=1mlogp(y(i)x(i))\max \sum_{i=1}^m \log p(y^{(i)} \mid x^{(i)}) or by directly minimizing the 0-1 classification training error: mini=1mI{h(x(i))y(i)}\min \sum_{i=1}^m \mathbb{I}\{h(x^{(i)}) \ne y^{(i)}\}

    Canonical Generative-Discriminative pairs include:

    • Discrete Naive Bayes and Logistic Regression.
    • Normal Discriminant Analysis (with diagonal or full covariance matrices) and Logistic Regression.
  9. Knowl 9 — Experimental Setup for Evaluating Naive Bayes and Logistic Regression

    experimental setup

    Empirical comparisons between generative Naive Bayes and discriminative logistic regression were conducted across 15 binary classification datasets from the UCI Machine Learning repository:

    • Continuous datasets (8): pima, adult (continuous), boston (predicting price above median), optdigits (digit '0' vs '1'), optdigits (digit '2' vs '3'), ionosphere, liver disorders, and sonar. Continuous features were normalized to [0,1][0, 1]. Naive Bayes assumed univariate Gaussians per feature with shared variance (equivalent to diagonal Normal Discriminant Analysis), regularized by adding ϵI\epsilon I to the covariance diagonal to ensure invertibility.
    • Discrete datasets (7): adult (discrete), promoters, lymphography, breast cancer, lenses (hard vs. soft contact lens), sick, and voting records. Discrete Naive Bayes used Laplace smoothing (l=1l = 1): p^(xi=1y=b)=#S{xi=1,y=b}+1#S{y=b}+2\hat{p}(x_i = 1 \mid y = b) = \frac{\#_S\{x_i = 1, y = b\} + 1}{\#_S\{y = b\} + 2}
    • Evaluation protocol: For each dataset, generalization error was evaluated as a function of training set size mm, averaged across 1000 independent random train/test splits (stratified such that each training split contained at least one instance per class).
    • Separable data handling: For linearly separable training splits where multiple separating hyperplanes exist, an MCMC sampler sampled classifiers uniformly over the separating hyperplanes, reporting the empirical average error across the sampled hyperplanes.
  10. Knowl 10 — Empirical Demonstration of Two Performance Regimes on UCI Benchmarks

    empirical result

    In empirical evaluations comparing Naive Bayes and logistic regression across 15 UCI benchmark datasets over varying training set sizes mm:

    • Two performance regimes: On most datasets (such as lymphography, promoters, sonar, boston, pima, and optdigits), the two predicted performance regimes appear clearly. At small sample sizes mm, Naive Bayes attains lower generalization error than logistic regression and approaches its asymptotic error rapidly. As mm increases, the error curve of logistic regression crosses below that of Naive Bayes, achieving lower asymptotic error.
    • Sample-constrained datasets: On small datasets with limited total samples (such as lenses, where the maximum available training size is m25m \le 25), logistic regression does not catch up to Naive Bayes because mm cannot be grown large enough to reach the large-sample regime (m=Ω(n)m = \Omega(n)).

Coverage note — None was omitted; all contributed definitions, sample complexity bounds, parameter convergence lemmas, discriminant scaling properties, two-regime theoretical characterizations, and empirical benchmark results were captured.

References

  1. 1.M. Anthony and P. Bartlett. Neural Network Learning: Theoretical Foundations. Cambridge University Press, 1999.
  2. 2.B. Efron. The efficiency of logistic regression compared to Normal Discriminant Analysis. Journ. of the Amer. Statist. Assoc., 70:892–898, 1975.
  3. 3.P. Goldberg and M. Jerrum. Bounding the VC dimension of concept classes parameterized by real numbers. Machine Learning, 18:131–148, 1995.
  4. 4.G.J. McLachlan. Discriminant Analysis and Statistical Pattern Recognition. Wiley, New York, 1992.
  5. 5.Y. D. Rubinstein and T. Hastie. Discriminative vs. informative learning. In Proceedings of the Third International Conference on Knowledge Discovery and Data Mining, pages 49–53. AAAI Press, 1997.
  6. 6.V. N. Vapnik. Statistical Learning Theory. John Wiley & Sons, 1998.

Citation

MLA
Ng, A., and M. Jordan. “On Discriminative Vs. Generative Classifiers: A Comparison of Logistic Regression and Naive Bayes”. Advances in Neural Information Processing Systems, vol. 14, 2001, https://proceedings.neurips.cc/paper_files/paper/2001/file/7b7a53e239400a13bd6be6c91c4f6c4e-Paper.pdf.
APA
Ng, A., & Jordan, M. (2001). On Discriminative vs. Generative Classifiers: A comparison of logistic regression and naive Bayes. Advances in Neural Information Processing Systems, 14. https://proceedings.neurips.cc/paper_files/paper/2001/file/7b7a53e239400a13bd6be6c91c4f6c4e-Paper.pdf
Chicago
Ng, A., and M. Jordan. 2001. “On Discriminative Vs. Generative Classifiers: A Comparison of Logistic Regression and Naive Bayes”. Advances in Neural Information Processing Systems 14. https://proceedings.neurips.cc/paper_files/paper/2001/file/7b7a53e239400a13bd6be6c91c4f6c4e-Paper.pdf.
Harvard
Ng, A. and Jordan, M. (2001) “On Discriminative vs. Generative Classifiers: A comparison of logistic regression and naive Bayes”, Advances in Neural Information Processing Systems. Curran Associates, Inc. Available at: https://proceedings.neurips.cc/paper_files/paper/2001/file/7b7a53e239400a13bd6be6c91c4f6c4e-Paper.pdf.
Vancouver
1. Ng A, Jordan M (2001) On Discriminative vs. Generative Classifiers: A comparison of logistic regression and naive Bayes. Advances in Neural Information Processing Systems 14:

BibTeX

@inproceedings{ng2001discriminative,
  title = {On Discriminative vs. Generative Classifiers: A comparison of logistic regression and naive Bayes},
  author = {Ng, Andrew and Jordan, Michael},
  year = {2001},
  booktitle = {Advances in Neural Information Processing Systems},
  publisher = {Curran Associates, Inc.},
  volume = {14},
  url = {https://proceedings.neurips.cc/paper_files/paper/2001/file/7b7a53e239400a13bd6be6c91c4f6c4e-Paper.pdf}
}
Metadata:DOI registry

Access the Paper

This paper is available from its original source. Click below to access the PDF.

Open PDF

License: Authors