Professional Documents
Culture Documents
Himanshu Saini
November 2022
A Naive Bayes classifier assumes that the effect of a particular feature in a class is
independent of other features and is based on Bayes’ theorem. Bayes’ theorem is a
mathematical equation used in probability and statistics to calculate conditional
probability. In other words, you can use this theorem to calculate the probability
of an event based on its association with another event.
The simple formula of the Bayes theorem is:
Where P(A) and P(B) are two independent events and (B) is not equal to zero.
Naive Bayes classifiers tend to perform especially well in any of the following
situations:
Let us now calculate the event occurring/classifying using the Naive Bayes
classification method by taking a simple example. Given an example of weather
conditions and playing sports, we need to calculate the probability of playing
sports and not playing sports. And classify whether players will play or not
depending on the weather condition. The sample data set is as follows:
You can use the frequency and likelihood tables to simplify prior and posterior
probability calculations. The Frequency table shows how often labels appear for
each feature. These tables will assist us in calculating the prior and posterior
probabilities.
The next step is to find the posterior probability, which can be easily be calculated
by:
Similarly, we can calculate the probability of not playing any sports when overcast
weather.
We can see that the probability of a Playing class is higher, so if the weather
is Overcast players will play sports.