A naive Bayes classifier is a simple probabilistic classifier based on applying Bayes' theorem with strong (naive) independence assumptions. In Mathematics, a classifier is a mapping from a (discrete or continuous Feature space X to a discrete set of labels Y. In Probability theory, Bayes' theorem (often called Bayes' law after Thomas Bayes) relates the conditional and marginal probabilities of two In Probability theory, to say that two events are independent intuitively means that the occurrence of one event makes it neither more nor less probable that the other A more descriptive term for the underlying probability model would be "independent feature model". In Probability theory, to say that two events are independent intuitively means that the occurrence of one event makes it neither more nor less probable that the other
Depending on the precise nature of the probability model, naive Bayes classifiers can be trained very efficiently in a supervised learning setting. Supervised learning is a Machine learning technique for learning a function from training data 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. Maximum likelihood estimation ( MLE) is a popular statistical method used for fitting a mathematical model to some data Bayesian probability interprets the concept of Probability as 'a measure of a state of knowledge'.
In spite of their naive design and apparently over-simplified assumptions, naive Bayes classifiers often work much better in many complex real-world situations than one might expect. Recently, careful analysis of the Bayesian classification problem has shown that there are some theoretical reasons for the apparently unreasonable efficacy of naive Bayes classifiers (Zhang04). Efficacy is the capacity to produce a desired size of an effect under Ideal or Optimal conditions An advantage of the naive Bayes classifier is that it requires a small amount of training data to estimate the parameters (means and variances of the variables) necessary for classification. Because independent variables are assumed, only the variances of the variables for each class need to be determined and not the entire covariance matrix.
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 plain English the above equation can be written as
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. In Probability theory, Bayes' theorem (often called Bayes' law after Thomas Bayes) relates the conditional and marginal probabilities of two 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. In the study of Probability, given two Random variables X and Y, the joint distribution of X and Y is the distribution Conditional probability is the Probability of some event A, given the occurrence of some other event B. Now the "naive" conditional independence assumptions come into play: assume that each feature Fi is conditionally independent of every other feature Fj for . In Probability theory, two events A and B are conditionally independent given a third event C precisely if the occurrence or non-occurrence In Probability theory, to say that two events are independent intuitively means that the occurrence of one event makes it neither more nor less probable that the other 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. In Probability theory and Statistics, the Bernoulli distribution, named after Swiss scientist Jakob Bernoulli, is a discrete Probability
All model parameters (i. e. , class priors and feature probability distributions) can be approximated with relative frequencies from the training set. These are maximum likelihood estimates of the probabilities. Non-discrete features need to be discretized first. In Mathematics, discretization concerns the process of transferring continuous models and equations into discrete counterparts Discretization can be unsupervised (ad-hoc selection of bins) or supervised (binning guided by information in training data).
If a given class and feature value never occur together in the training set then the frequency-based probability estimate will be zero. This is problematic since it will wipe out all information in the other probabilities when they are multiplied. It is therefore often desirable to incorporate a small-sample correction in all probability estimates such that no probability is ever set to be exactly zero. A pseudocount is a count added to observed Data in order to change the Probability in a model of those data which is known not to be zero
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. In Statistics, the method of maximum a posteriori (MAP or posterior mode) estimation can be used to obtain a point estimate of an unobserved The corresponding classifier is the function classify defined as follows:
One should notice that the independence assumption may lead to some unexpected results in the calculation of posteriori probability. In some circumstances when there is a dependency between observations, the above-mentioned probability may contradict with the second axiom of probability by which any probability must be less than or equal to one.
Despite the fact that the far-reaching independence assumptions are often inaccurate, the naive Bayes classifier has several properties that make it surprisingly useful in practice. In particular, the decoupling of the class conditional feature distributions means that each distribution can be independently estimated as a one dimensional distribution. This in turn helps to alleviate problems stemming from the curse of dimensionality, such as the need for data sets that scale exponentially with the number of features. The curse of dimensionality is a term coined by Richard Bellman to describe the problem caused by the exponential increase in Volume associated with adding 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; hence class probabilities do not have to be estimated very well. In other words, the overall classifier is robust enough to ignore serious deficiencies in 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. Document classification/categorization is a problem in Information science. Consider the problem of classifying documents by their content, for example into spam and non-spam E-mails. Spamming is the abuse of electronic messaging systems to indiscriminately send unsolicited bulk messages Electronic mail, often abbreviated to e-mail, email, or originally eMail, is a Store-and-forward method of writing sending receiving 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?" In other words, what is ?
Now, by their definition, (see Probability axiom)
Bayes' theorem manipulates these into a statement of probability in terms of likelihood. In Probability theory, the Probability P of some event E, denoted P(E is defined in such a way that P satisfies the In Statistics, the likelihood function (often simply the likelihood) is a function of the Parameters of a Statistical model that plays a key role
Assume for the moment that there are only two classes, S and ¬S (e. g. spam and not spam).
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 likelihood ratio often denoted by \Lambda (the capital Greek letter Lambda) is the ratio of the maximum Probability of a Result 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 Mathematics, the logarithm of a number to a given base is the power or Exponent to which the base must be raised in order to produce The likelihood ratio often denoted by \Lambda (the capital Greek letter Lambda) is the ratio of the maximum Probability of a Result 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. A sigmoid function is a Mathematical function that produces a sigmoid curve &mdash a curve having an "S" shape The logit function is an important part of Logistic regression: for more information please see that article )
Finally, the document can be classified as follows. It is spam if , otherwise it is not spam.