Naive Bayesian classification |
Naive Bayesian classification is a simple probabilistic classification method. A more descriptive term for the underlying probability model is independent
feature model. The term naive Bayes refers to the fact that the probability model can be derived using Bayes' Theorem (credited to Thomas Bayes) and that it incorporates strong independences assumption that often have no bearing in reality,
hence are (deliberately) naive. Depending on the precise nature of the probability model, naive Bayes classifiers can be trained
very efficiently in a supervised learning setting. In many
practical applications, parameter estimation for naive Bayes models uses the method of maximum likelihood; in other words, one can work with the naive Bayes model without believing in
Bayesian probability or using any Bayesian methods.
Abstractly, the probability model for a classifier is a conditional model
-
over a dependent class variable C with a small number of outcomes or classes,
conditional on several feature variables F1 through Fn. The problem is that if the number of features n
is large or when a feature can take on a large number of values, then basing such a model on probability tables is infeasible. We
therefore reformulate the model to make it more tractable.
Using Bayes' Theorem, we write
-
In practice we are only interested in the numerator of that fraction, since the denominator does not depend on C and the values of the features Fi are given, so
that the denominator is effectively constant. The numerator is equivalent to the joint probability model
-
which can be rewritten as follows, using repeated applications of the definition of conditional probability:
-
-
-
-
-
and so forth. Now the "naive" conditional independence assumptions come into play: assume that each feature Fi is conditionally independent of every other feature Fj
( ). This means that
-
and so the joint model can be expressed as
-
-
This means that under the above independence assumptions, the conditional distribution over the class variable C can be expressed like this:
-
where Z is a scaling factor dependent only on , i.e., a constant if the values of the feature variables are
known.
Models of this form are much more manageable, since they factor into a so-called class prior p(C) and independent probability distributions . If there are k classes
and if a model for p(Fi) can be expressed in terms of r parameters, then the corresponding naive Bayes model has (k - 1) + n r
k parameters. In practice, often k = 2 (binary classification) and r = 1 (Bernoulli variables as features) are common, and so the total number of parameters of the naive Bayes
model is 2n + 1, where n is the number of binary features
used for prediction.
The discussion so far has derived the independent feature model, that is, the naive Bayes probability model.
The naive Bayes classifier combines this model with a decision rule. One common rule is to
pick the hypothesis that is most probable; this is known as the maximum a posteriori or MAP decision rule. The
corresponding classifier is the function classify defined as follows:
-
In a supervised learning setting, one wants to estimate
the parameters of the probability model. Because of the independent feature assumption, it suffices to estimate the class prior
and the conditional feature models independently, using the method of maximum likelihood, Bayesian inference
or other parameter estimation procedures.
The naive Bayes classifier has several properties that make it surprisingly useful in practice, despite the fact that the
far-reaching independence assumptions are often violated. Like all probabilistic classifiers under the MAP decision rule, it
arrives at the correct classification as long as the correct class is more probable than any other class; class probabilities do
not have to be estimated very well. In other words, the overall classifier is robust to serious deficiencies of its underlying
naive probability model. Other reasons for the observed success of the naive Bayes classifier are discussed in the literature
cited below.
Here is a worked example of naive Bayesian classification to the document
classification problem. Consider the problem of classifying documents by their content, for example into spam and non-spam E-mails. Imagine that documents
are drawn from a number of classes of documents which can be modelled as sets of words where the (independent) probability that
the i-th word of a given document occurs in a document from class C can be written as
-
(For this treatment, we simplify things further by assuming that the probability of a word in a document is independent of the
length of a document, or that all documents are of the same length).
Then the probability of a given document D, given a class C, is
-
The question that we desire to answer is: "what is the probability that a given document D belongs to a given class
C?"
Now, by their definition, (see Probability axiom)
-
and
-
Bayes' theorem manipulates these into a statement of probability in terms of likelihood.
-
Assume for the moment that there are only two classes, S and ¬S.
-
and
-
Using the Bayesian result above, we can write:
-
-
Dividing one by the other gives:
-
Which can be re-factored as:
-
Thus, the probability ratio p(S | D) / p(¬S | D) can be expressed in terms of a series of
likelihood ratios. The
actual probability p(S | D) can be easily computed from log (p(S | D) / p(¬S |
D)) based on the observation that p(S | D) + p(¬S | D) = 1.
Taking the logarithm of all these ratios, we have:
-
This technique of "log-likelihood ratios" is a common
technique in statistics. In the case of two mutually exclusive alternatives (such as this example), the conversion of a
log-likelihood ratio to a probability takes the form of a sigmoid curve:
see logit for details.
In real life, the naive Bayes approach is more powerful than might be expected from the extreme simplicity of its model; in
particular, it is fairly robust in the presence of non-independent attributes wi. Recent theoretical analysis has
shown why the naive Bayes classifier is so robust.
See also:
References
- Pedro Domingos and Michael Pazzani. "On the optimality of the simple Bayesian classifier under zero-one loss". Machine
Learning, 29:103-130, 1997. (also online at CiteSeer : [1] )
- Irina Rish. "An empirical study of the naive Bayes classifier". IJCAI 2001 Workshop on Empirical Methods in Artificial
Intelligence. (available online: PDF , PostScript )
External links
|