Bayesian Classification
Bayesian classifiers are statistical classifiers based on Bayes' theorem. They predict the class with the maximum posterior probability, are competitive in accuracy with decision trees and neural nets, and are extremely fast even on large databases. The naive Bayes classifier assumes class-conditional independence of attributes.
1. Bayes' Theorem
| Term | Name | Meaning |
|---|---|---|
| prior probability | probability that hypothesis holds before seeing data | |
| likelihood | probability of observing evidence given | |
| evidence | prior probability of the evidence (constant for all classes) | |
| posterior probability | probability of after seeing |
For classification with class set and attribute tuple :
The denominator is the same for every class, so the decision rule is:
If priors are unknown, (fraction of training tuples in the class).
2. The "Naive" Independence Assumption
Attributes are assumed conditionally independent given the class (no dependence relationships among attributes):
Then
Lazy learning: naive Bayes needs no model building — probabilities are computed at classification time from the training set.
3. Worked Example (buys_computer, 14 tuples)
Class priors: , (i.e. 9/14 and 5/14).
Class-conditional counts:
| Attribute value | yes | no | Attribute value | yes | no |
|---|---|---|---|---|---|
| age = youth | 2 | 3 | income = high | 2 | 2 |
| age = middle | 4 | 0 | income = medium | 4 | 2 |
| age = senior | 3 | 2 | income = low | 3 | 1 |
| student = yes | 6 | 1 | credit = fair | 6 | 2 |
| student = no | 3 | 4 | credit = excellent | 3 | 3 |
Classify X = (\text{age}=youth,\ income=medium,\ student=yes,\ credit=fair})
For :
For :
Since → buys_computer = yes.
4. Zero-Frequency Problem and Laplace (Additive) Smoothing
If a class-attribute value never appears in the training data, and the whole product becomes 0, wiping out the other evidence.
Laplace smoothing:
where = number of training tuples of class having value , = number of tuples of class , and = number of distinct values of the attribute. This is a Bayesian estimate — a uniform Dirichlet prior of .
5. Handling Numeric Attributes
Assume a Gaussian (normal) distribution per attribute per class, then use the density:
where and are the mean and standard deviation of attribute values for the class. Example: for income = 120K and class yes with : .
(Discretisation into intervals is an alternative to the Gaussian assumption.)
6. Alternative: Bayesian Belief Networks (BBN)
When attributes are dependent, naive Bayes is unrealistic. A Bayesian belief network is a DAG where nodes = random variables and arcs = probabilistic dependencies; each node carries a conditional probability table (CPT) given its parents:
FamilyHistory Smoker
\ /
\ /
\ / P(LungCancer | FH, Smoker) given by CPT
LungCancer <-- from both
/ \
PositiveXRay Dyspnea
BBNs can answer arbitrary queries with evidence (inference is NP-hard in general; approximations/junction trees used), give believable results with thousands of variables and are interpretable because structure shows dependencies.
Training a BBN: parameters (CPTs) are estimated by counting if the structure is known; structure learning is harder (hill climbing, K2, MDL/BIC scoring). Incomplete data needs EM or gradient methods.
7. Advantages and Limitations
Advantages
- Easy, fast and highly scalable — no iterative parameter search, one pass over training data.
- Robust to isolated noise (noise averaged out) and handles missing values (skip that attribute's probability term).
- Works well on high-dimensional data; no need for many iterations/tuning; can be used for incremental learning.
- Provides probabilistic predictions (useful for costs/thresholds) and a clear Bayesian foundation for combining prior domain knowledge.
- BBN extension models dependencies → better accuracy when attributes correlate.
Limitations
- Strong (naive) independence assumption — often violated, which can degrade accuracy (though the decision may still be right because the ranking is preserved).
- Sensitivity to correlated/redundant attributes — duplicated attributes get their evidence counted twice; requires attribute selection (or BBN).
- Zero-frequency estimates need Laplace smoothing; numeric attributes need discretisation or a normality assumption.
- No output is a readable model (no rules/tree), and Bayesian belief network inference and structure learning are computationally expensive.
8. Exam Points
- State Bayes' theorem and explain the naive Bayes classifier with the conditional independence assumption — 7-10 marks (very frequent).
- Numerical: classify a given tuple using the buys_computer/weather data and show all probabilities — 10 marks (extremely frequent).
- Explain the zero-frequency problem, Laplace smoothing and numeric attribute handling (Gaussian) — 5-7 marks.
- Short note on Bayesian belief networks with CPT and an example DAG — 5-7 marks.
- List advantages and limitations of Bayesian classification — 5 marks.