What are Naive Bayes classifiers?

In machine learning, Naive Bayes classifiers are widely used for classification because, when the assumption of independence holds, they are easy to implement and yield better results than other sophisticated predictors.

Naive Bayes classifiers are based on Bayes’ theorem and assume that the occurrence or absence of a feature does not influence the presence or absence of some other feature.

Types

  • Gaussian Naive Bayes classifier: used when features are not discreet.

  • Multinomial Naive Bayes Classifier: used when features follow a multinomial distribution.

  • Bernoulli Naive Bayes classifier: used when features are of the boolean type.

Derivation

Let’s take a look at the Mathematics behind Naive Bayes classifiers.

The equation for Bayes theorem is:

P(classX)=P(Xclass)P(class)/P(X)P(class|X) = P(X|class)P(class)/P(X)

A class variable is something that the classifier is trying to classify. For instance, when trying to classify an email as spam or not, “is spam” is the class variable.

In the equation above, classclass is the class variable and XX is the set of features. X=(x1,x2,...xn)X = (x_1, x_2, ... x_n)

The above formula can be rewritten as:

P(classx1...xn)=P(x1class)...P(xnclass)P(class)/P(x1)...P(xn)P(class|x_1 ... x_n) = P(x_1|class)... P(x_n|class)P(class)/P(x_1)...P(x_n)

Notice that for all entries in the given dataset, the denominator will not change. Hence, the denominator can be ignored.

P(classx1...xn)P(x1class)...P(xnclass)P(class)P(class|x_1 ... x_n) \propto P(x_1|class)... P(x_n|class)P(class)

For all outcomes of the class variable, the class variable with the maximum probability needs to be found using:

class=argmax(P(x1class)...P(xnclass)P(class))class = argmax(P(x_1|class)... P(x_n|class)P(class))

Note: Different Naive Bayes classifiers make different assumptions regarding the distribution of P(xiclass)P(x_i | class).

Applications

Some​ applications that use Naive Bayes classifiers are:

  • Spam Filtering

  • Text Analysis

  • Recommendation Systems

Copyright ©2024 Educative, Inc. All rights reserved