Source: Unit-4.pdf.

Core idea

Bayesian learning updates belief in a hypothesis using observed data. Naive Bayes turns this into a fast classifier by assuming independent features; EM estimates model parameters when part of the data is hidden or missing.

1. Conditional probability and Bayes’ theorem

Conditional probability is the probability of event when event is known to have occurred:

Bayes’ theorem reverses a conditional probability:

TermMeaning
Prior probability: belief in before observing evidence.
Likelihood: probability of evidence if is true.
Evidence/marginal probability of observing .
Posterior probability: belief in after observing .
Picnic-day calculation

Suppose , , and . Then

A cloudy morning gives a 12.5% chance of rain under these assumptions.

Why probabilistic reasoning is useful

  • represents uncertainty in complex environments;
  • combines prior knowledge with current evidence;
  • naturally supports diagnosis, forecasting, robotics, spam filtering, search, and sensor fusion;
  • allows information from different sources to be combined consistently.
Base-rate trap

A highly accurate test does not automatically mean that a positive test implies a high chance of disease. The prior/prevalence matters.

PYQ — CT Set B, Q1(b)

Original question scan — Class Test I Set B Q1(b)

Meningitis causes a stiff neck with probability 0.5; and . What is ? Bayes’ rule gives , or 0.2%. The prior matters: the symptoms are much more common than meningitis.

The total probability theorem is for mutually exclusive, exhaustive hypotheses with defined conditional probabilities.

PYQ — CT Set A, Q1(c)

Original question scan — Class Test I Set A Q1(c)

A student studies regularly with probability 0.6. High marks occur with probability 0.8 if regular and 0.3 if irregular. Given high marks, which is more likely? The evidence is . Thus and . The student is more likely to be regular.

2. Bayesian learning

In machine learning, let:

  • be a hypothesis space;
  • be one candidate hypothesis;
  • be observed training data.

Bayesian learning chooses or reasons about hypotheses using their posterior probability:

QuantityMeaning
Prior: initial belief that hypothesis is correct.
Likelihood: probability of observing the data if holds.
Probability of the observed data; normalises all posterior probabilities.
Posterior: confidence in after seeing .

The posterior incorporates both the observed training data and any justified prior knowledge. Bayesian reasoning can also analyse algorithms that do not explicitly calculate probabilities.

3. Naive Bayes classifier

Naive Bayes is a probabilistic classifier based on Bayes’ theorem. It assumes that features are conditionally independent once the class is known.

For feature vector and class :

Therefore the classifier predicts

The denominator is the same for every candidate class, so it is not needed for choosing the largest posterior.

Procedure

  1. Compute each class prior from the training data.
  2. Compute the likelihood of each feature value given each class, .
  3. Multiply the prior and likelihoods to obtain an unnormalised posterior score for each class.
  4. Predict the class with the greatest score.
Play-tennis style decision

To classify whether players will play when weather is sunny, calculate and . The class with the larger posterior is the prediction.

Advantages

  • simple, fast, and easy to implement;
  • needs comparatively little training data;
  • supports multiple classes naturally;
  • scales well to high-dimensional data, especially text;
  • often performs well when conditional independence is a reasonable approximation.

Limitations

  • Features are rarely truly conditionally independent in real data.
  • A categorical value absent from training can receive zero probability: the zero-frequency problem.
  • The predicted class can be good even when the posterior probability estimates are poorly calibrated.
  • Numerical Naive Bayes commonly assumes a distribution such as Gaussian; this assumption can be wrong.

Laplace smoothing

To avoid a zero likelihood for an unseen categorical value, add a small pseudo-count. For possible values:

Usually , called Laplace/add-one smoothing.

Applications

  • real-time classification;
  • multi-class prediction;
  • spam filtering and general text classification;
  • sentiment analysis;
  • recommendation systems when combined with other techniques.

4. Bayes-optimal classification, MAP, ML, and Gibbs

Bayes-optimal classification

A Bayes-optimal classifier considers all hypotheses and weights each prediction by the hypothesis posterior. For possible output values :

It achieves the best possible expected classification performance for the stated hypothesis space and probabilities, but can be expensive because it must consider every hypothesis.

MAP: maximum a posteriori hypothesis

A MAP hypothesis is the most probable hypothesis after observing data:

The second form follows because is identical for every during maximisation.

Example

If , , and , then .

Maximum likelihood (ML) hypothesis

If every hypothesis has the same prior probability, , then the prior does not affect the ranking:

MethodWhat is maximisedUses prior knowledge?
Bayes-optimal classifierPosterior-weighted prediction over all hypothesesYes
MAPYes
Maximum likelihoodOnly implicitly through assumptions; equal priors remove it from the choice

Gibbs algorithm

The Gibbs algorithm is a cheaper alternative to Bayes-optimal classification:

  1. Randomly choose one hypothesis according to the posterior distribution .
  2. Use that hypothesis to classify the next instance.

It avoids combining the predictions of every hypothesis, but is not as optimal as Bayes-optimal classification.

5. Bayesian belief networks

A Bayesian belief network (Bayesian network/Bayes net) is a probabilistic graphical model that represents variables and their conditional dependencies with a directed acyclic graph (DAG).

It has two parts:

  1. A DAG: nodes are random variables and directed edges show direct conditional influence.
  2. Conditional probability tables (CPTs): each node specifies probabilities conditioned on its parents.

Components and interpretation

  • A node can represent a discrete or continuous random variable.
  • An arrow means is a parent of and directly influences its conditional distribution.
  • The absence of an edge does not mean variables are always unconditionally independent; it means no direct relationship is represented in that graph.
  • The DAG cannot contain a directed cycle.

For variables , the joint distribution factorises as

Bayesian networks can combine expert knowledge with data and support probabilistic inference under uncertainty.

6. Text classification with Naive Bayes

Text classification assigns a document to one class from a fixed set

Examples include spam detection, topic/genre assignment, authorship identification, age/gender or language identification, and sentiment analysis.

Bag-of-words representation

The bag-of-words model represents a document by the words it contains, commonly as word counts or binary presence/absence values. It ignores word order and grammar.

For a document and class :

Naive Bayes chooses the class with the largest posterior. Under the word-independence assumption, the likelihood is formed from the individual word probabilities given the class.

Plain meaning

A spam classifier may learn that words such as “winner” and “free” occur more often in spam than in ordinary mail. Their presence raises the spam score, while smoothing prevents a new word from making the entire score zero.

7. Expectation-Maximization (EM) algorithm

The Expectation-Maximization (EM) algorithm estimates model parameters when data is incomplete or contains latent variables: variables not directly observed but inferred from observed data.

Examples: missing values, unknown cluster membership, hidden states in a Hidden Markov Model (HMM).

EM cycle

  1. Start with initial parameter values .
  2. E-step (Expectation): use observed data and current parameters to estimate the expected values/distribution of hidden or missing variables.
  3. M-step (Maximization): update parameters to maximise the expected complete-data likelihood from the E-step.
  4. Check for convergence. If not converged, repeat E-step and M-step.

Uses

  • filling/estimating missing data;
  • latent-variable estimation;
  • unsupervised clustering, including mixture models;
  • parameter estimation for HMMs.

Advantages and limitations

AdvantagesLimitations
Each iteration does not decrease the likelihood.Can converge slowly.
E- and M-steps are often simple for common probabilistic models.May converge to a local optimum rather than the global optimum.
Some M-step updates have closed-form solutions.Requires an appropriate probabilistic model and an initialisation choice.
Final revision

Bayes: prior + likelihood → posterior.
Naive Bayes: assume conditionally independent features and select the largest posterior.
MAP: best posterior hypothesis; ML: best likelihood when priors are equal.
EM: alternate expected hidden values and parameter updates until convergence.