In the general formulation of Bayes Decision Theory, we aim to minimize the probability of error (or more generally, the expected risk) by assigning a feature vector x to the class ωi that maximizes the posterior probability P(ωi∣x). Using Bayes’ theorem, this is often equivalent to maximizing the product of the likelihood P(x∣ωi) and the prior probability P(ωi):
Choose ωi such that P(x∣ωi)P(ωi)≥P(x∣ωj)P(ωj) for all j=i
While the framework remains the same whether the features are continuous or discrete, the nature of the features significantly impacts how we model and estimate the class-conditional probability density (or probability mass function) P(x∣ωi). This section focuses on the case where the feature vector x=[x1,x2,...,xd]T consists of discrete features.
When features xj are discrete, x can take on a finite number of possible values. Let Vj be the number of possible values for feature xj. Then the total number of possible feature vectors x is V=∏j=1dVj.
Estimating P(x∣ωi) directly involves estimating the probability for each possible configuration of x for each class ωi.
Curse of Dimensionality: If the dimensionality d is large, or if the features xj can take many values (Vj is large), the total number of possible vectors V becomes enormous.
Data Sparsity: To get reliable estimates for P(x∣ωi) for every possible x, we would need a vast amount of training data. Many possible feature vectors might not appear even once in the training set for a given class, leading to zero probability estimates, which is problematic.
Modeling P(x∣ωi) for Discrete Features: The Naive Bayes Assumption¶
Due to the challenges above, directly estimating the full joint probability P(x∣ωi)=P(x1,x2,...,xd∣ωi) is often infeasible. A common and simplifying approach is to assume conditional independence of the features given the class.
This assumption dramatically simplifies the problem: instead of estimating one large joint probability table, we only need to estimate d smaller probability distributions P(xj∣ωi) for each class ωi.
The parameters P(xj=v∣ωi) and the prior probabilities P(ωi) are typically estimated from the training data using Maximum Likelihood Estimation (MLE) or smoothed versions (like Laplace smoothing) to avoid zero probabilities:
Prior Probability:P^(ωi)=Ni/N
Class-Conditional Feature Probability (MLE):P^(xj=v∣ωi)=Nijv/Ni
Class-Conditional Feature Probability (Laplace Smoothing):P^(xj=v∣ωi)=(Nijv+α)/(Ni+αVj)
Case Study: Independent Binary Features (Section 2.9.1)¶
A particularly important special case arises when all d features are binary, i.e., xj∈{0,1}. This is common in areas like document classification (presence/absence of words) or medical diagnosis (presence/absence of symptoms).
Let’s define the probability that feature j is present (takes value 1) for class ωi as:
To classify a new sample x, we use the decision rule based on the discriminant functions gi(x). For convenience, we use the log-posterior (ignoring the constant P(x) term):
The weight vector wi has components wji=log1−pjipji (the log-odds for feature j being 1 in class i). (Eq.90a)
The bias term (or threshold) wi0=∑k=1dlog(1−pki)+logP(ωi). (Eq.90b, index updated)
Key Result: For binary features under the Naive Bayes assumption, the optimal Bayes discriminant function gi(x) is a linear discriminant function. This provides an interesting link between generative models (like Naive Bayes, which models P(x∣ωi) and P(ωi)) and discriminative models (which directly model the decision boundary or discriminant functions, often assuming linearity).
The decision boundary between two classes, say ωi and ωk, is found by setting gi(x)=gk(x), which leads to a linear equation in x:
The parameters pji=P(xj=1∣ωi) and P(ωi) are estimated from the training data, often using MLE or MAP (e.g., with Laplace smoothing).
MLE: p^ji=Total number of samples in class ωiNumber of times xj=1 in class ωi
MLE: P^(ωi)=Total number of samplesTotal number of samples in class ωi
Smoothing is typically applied, especially for pji, to avoid issues with zero counts leading to log probabilities of −∞.
Handling discrete features in Bayesian decision theory often requires simplifying assumptions due to the curse of dimensionality. The Naive Bayes assumption (conditional independence of features given the class) is a common and effective approach.
It simplifies the estimation of class-conditional probabilities from O(V) parameters to O(d×Vˉ) parameters (where Vˉ is the average number of values per feature).
In the specific case of independent binary features, the Naive Bayes classifier results in a linear discriminant function. This highlights a connection between generative probability modeling and linear classifiers.
While the independence assumption might seem overly simplistic (“naive”), Naive Bayes classifiers often perform surprisingly well in practice, particularly in domains like text classification.
For further information see section 2.9 of Duda et al.