Self-supervised Naive Bayes

Machine Learning
Introduced by
Nigam, K.; McCallum, A. K.; Thrun, S.; Mitchell, T.
Year
2000
Type
Self-supervised generative classifier
Family
Machine learning

What does it do?

Self-supervised Naive Bayes extends the Naive Bayes classifier to use unlabeled data alongside a small labeled set.

It uses the Expectation-Maximization (EM) algorithm to alternate between estimating soft class memberships for the unlabeled examples under the current model and re-estimating the model from the weighted data. Nigam et al. (2000) applied EM to Naive Bayes for text classification using both labeled and unlabeled documents. The same family of methods appears in the literature under several names, including EM Naive Bayes, semi-supervised Naive Bayes and pseudo-label Naive Bayes. The name used on this page refers to the model supplying its own labels through its posterior estimates.

The intuition behind the method

Naive Bayes learns a generative model of each class from labeled examples. Once that initial model exists, it can assign each unlabeled point a probability of belonging to each class. These probabilities act as fractional labels, and refitting the model on them can sharpen the estimates of class priors and feature likelihoods. The loop helps only if the initial guesses are roughly right, because each round reuses the model's own beliefs. Because the Naive Bayes M-step has a closed form, each iteration is a single pass over the data rather than a numerical optimization.

History

Nigam, McCallum, Thrun and Mitchell (2000) combined Naive Bayes with the EM algorithm for text classification using labeled and unlabeled documents, as the title of their Machine Learning article indicates. Reported gains and experimental details are given in the original article and should be checked there before the method is compared against published results.

When to use it

Choose this method when labeled examples are few relative to the number of features and classes, but unlabeled examples from the same source are plentiful. This is common for text documents, where annotation is expensive. It fits discrete count features such as word counts, where the multinomial Naive Bayes likelihood is a reasonable model. Avoid it when labeled data already cover each class well, when features are strongly dependent so that the independence assumption is poor, when the unlabeled pool comes from a shifted distribution, or when a fully supervised and easily audited model is required. It is also a poor choice when the initial supervised model is so weak that the EM loop would reinforce its errors. Before relying on it, check that every class has at least one labeled example, compare EM against the supervised Naive Bayes baseline on held-out labeled data, and drop the EM step if the baseline is weak or one class comes to dominate the solution.

Limitations and considerations

  • The independence assumption of Naive Bayes is inherited: when features are strongly correlated, the posteriors used as fractional labels are biased, and EM can reinforce that bias.
  • EM increases the likelihood of the training data at each step but does not guarantee better classification accuracy, and it converges to a local optimum that depends on the initial supervised fit.
  • The method assumes unlabeled examples come from the same distribution as the labeled examples; covariate shift can degrade performance.
  • The discrete-count formulation shown here does not handle continuous features directly. They require discretization or a Gaussian likelihood, which changes the M-step.
  • The unlabeled-data weight must be chosen. A high weight lets noise in the unlabeled pool dominate, and choosing it requires held-out labeled data.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Uses unlabeled examples that a purely supervised Naive Bayes model would ignore, which can help most when labeled data are scarce.
  • Each EM iteration is inexpensive for Naive Bayes because the M-step is closed-form and needs a single pass over the data, so large unlabeled pools remain tractable.
  • Outputs per-class posterior probabilities from the generative model, useful for ranking and thresholding. These values are often extreme for Naive Bayes, so they should be checked on held-out data before being read as calibrated probabilities.
  • The weight on unlabeled examples gives direct control over how strongly the unlabeled signal shapes the parameters.
  • Well suited to high-dimensional sparse count features such as bag-of-words representations, where the per-feature likelihood factorization is straightforward to estimate.
  • Requires little machinery beyond a standard Naive Bayes implementation with weighted counts.

Applications

  • Text classification where labeled documents are costly to obtain and unlabeled documents from the same source are plentiful, the setting studied by Nigam et al. (2000).
  • Other domains with few labels and a large pool of unlabeled examples from the same distribution may be candidates, provided the independence assumption is reasonable for the chosen features.

How it works

How it works

1

A standard Naive Bayes classifier is fitted to the labeled examples, estimating class priors and per-feature likelihoods. Laplace smoothing keeps feature values that do not occur in the labeled set from receiving zero probability.

2

With the current parameters, the posterior class probability of each unlabeled example is computed from the class prior and the product of its feature likelihoods. The result is a soft assignment across classes that reflects how confident the model is about each example.

Formula
P(y_i | x_i, \theta) \propto P(y_i | \theta) \prod_j P(x_{ij} | y_i, \theta)
3

The E-step posteriors are used as fractional labels. Each unlabeled example contributes to every class in proportion to its posterior rather than receiving one hard label, so an example the model is unsure about spreads its weight across classes.

4

Class priors and feature likelihoods are re-estimated from the labeled examples together with the weighted unlabeled examples, maximizing the expected complete-data log-likelihood. For Naive Bayes this has a closed form and requires one pass over the data.

5

The E-step and M-step alternate until the change in log-likelihood falls below a convergence threshold. A weight on the unlabeled examples can be set below one so that they contribute less than the labeled examples, which limits how far a large unlabeled pool can shift the model.

Common pitfalls

  • Using too few labeled examples to initialize the model, causing the EM to converge to a class-collapsed solution where one class dominates.
  • Omitting the unlabeled-data weight parameter and allowing the large unlabeled corpus to overwhelm the labeled supervision signal.
  • Evaluating only on the training set without a held-out labeled test set, masking whether self-supervision actually helped.
  • Applying the method when unlabeled data come from a different domain or time period than the labeled set.
  • Treating the pseudo-label EM output as equivalent to a fully supervised model for regulatory or high-stakes decisions.

Frequently asked questions

How many labeled examples are needed to start?

There is no fixed minimum number of labeled examples. With very few labels the initial model is weak and EM can settle on a poor solution, so the labeled set should contain at least one example of every class, and performance should be compared on held-out data before and after EM.

What is the unlabeled-data weight and how should I set it?

The weight, often written lambda, scales the contribution of unlabeled examples relative to labeled ones. A weight below one limits the influence of the unlabeled pool, while a weight of one gives unlabeled examples the same per-example weight as labeled ones. Choose it on held-out labeled data rather than on the training fit.

How is this different from semi-supervised Naive Bayes?

The term self-supervised refers to the fact that the supervision for unlabeled examples comes from the model's own posterior estimates rather than new human annotation. Semi-supervised Naive Bayes is used for the same EM setting with labeled and unlabeled data, so the two names refer to closely related, largely overlapping methods. The more general term is semi-supervised learning.

Does EM always improve performance over supervised Naive Bayes?

No. EM increases the likelihood of the training data, but that does not guarantee higher accuracy. If the independence assumption is badly violated, the unlabeled pool is noisy, or its distribution differs from the labeled set, performance can fall. Compare against the purely supervised model on a held-out labeled test set before deploying.

Can this be applied to continuous features?

Not directly with the multinomial formulation described here. Discretizing continuous features keeps the count-based model. Using a Gaussian Naive Bayes base model changes the likelihood and the M-step, while the overall EM loop structure stays the same.

Related methods

Sources

  1. Nigam, K., McCallum, A. K., Thrun, S., & Mitchell, T. (2000). Text classification from labeled and unlabeled documents using EM. Machine Learning, 39(2-3), 103–134.

    Open DOI reference
  2. Chapelle, O., Scholkopf, B., & Zien, A. (Eds.) (2006). Semi-supervised Learning. MIT Press.

    ISBN: 978-0-262-03358-9