Naive Bayes

Naive Bayes is a classification algorithm based on Bayes' probability theorem and conditional independence hypothesis on the features. Given a set of m features, Naive Bayes, and a set of labels (classes) Naive Bayes, the probability of having label c (also given the feature set xi) is expressed by Bayes' theorem:

Naive Bayes

Here:

  • Naive Bayes is called the likelihood distribution
  • Naive Bayes is the posteriori distribution
  • Naive Bayes is the prior distribution
  • Naive Bayes is called the evidence

The predicted class associated with the set of features Naive Bayes will be the value p such that the probability is maximized:

Naive Bayes

However, the equation cannot be computed. So, an assumption is needed.

Using the rule on conditional probability Naive Bayes, we can write the numerator of the previous formula as follows:

Naive Bayes
Naive Bayes
Naive Bayes

We now use the assumption that each feature xi is conditionally independent given c (for example, to calculate the probability of x1 given c, the knowledge of the label c makes the knowledge of the other feature x0 redundant, Naive Bayes):

Naive Bayes

Under this assumption, the probability of having label c is then equal to:

Naive Bayes ––––––––(1)

Here, the +1 in the numerator and the M in the denominator are constants, useful for avoiding the 0/0 situation (Laplace smoothing).

Due to the fact that the denominator of (1) does not depend on the labels (it is summed over all possible labels), the final predicted label p is obtained by finding the maximum of the numerator of (1):

Naive Bayes ––––––––(2)

Given the usual training set Naive Bayes, where Naive Bayes(M features) corresponding to the labels set Naive Bayes, the probability P(y=c) is simply calculated in frequency terms as the number of training examples associated with the class c over the total number of examples, Naive Bayes. The conditional probabilities Naive Bayes instead are evaluated by following a distribution. We are going to discuss two models, Multinomial Naive Bayes and Gaussian Naive Bayes.

Multinomial Naive Bayes

Let's assume we want to determine whether an e-mail s given by a set of word occurrences Multinomial Naive Bayes is spam (1) or not (0) so that Multinomial Naive Bayes. M is the size of the vocabulary (number of features). There are Multinomial Naive Bayes words and N training examples (e-mails).

Each email x(i) with label yi such that Multinomial Naive Bayes is the number of times the word j in the vocabulary occurs in the training example l. For example, Multinomial Naive Bayes represents the number of times the word 1, or w1, occurs in the third e-mail. In this case, multinomial distribution on the likelihood is applied:

Multinomial Naive Bayes

Here, the normalization constants in the front can be discarded because they do not depend on the label y, and so the arg max operator will not be affected. The important part is the evaluation of the single word wj: probability over the training set:

Multinomial Naive Bayes

Here Niy is the number of times the word j occurs, that is associated with label y, and Ny is the portion of the training set with label y.

This is the analogue of Multinomial Naive Bayes,Multinomial Naive Bayes on equation (1) and the multinomial distribution likelihood. Due to the exponent on the probability, usually the logarithm is applied to compute the final algorithm (2):

Multinomial Naive Bayes

Gaussian Naive Bayes

If the features vectors x(i) have continuous values, this method can be applied. For example, we want to classify images in K classes, each feature j is a pixel, and xj(i) is the j-th pixel of the i-th image in the training set with N images and labels Gaussian Naive Bayes. Given an unlabeled image represented by the pixels Gaussian Naive Bayes, in this case, Gaussian Naive Bayesin equation (1) becomes:

Gaussian Naive Bayes

Here:

Gaussian Naive Bayes

And:

Gaussian Naive Bayes
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.5.15