Have you ever wondered :

How your suspected/ marketing emails are automatically put in the junk / spam box and not the primary inbox?

How we can predict if today it will rain or not ?

If you have these questions, then just go through the article and you will be able to get a fair idea how these predictions are made which is very useful in day to day life.

In real life we all face circumstances where based on certain conditions and prior knowledge we want to predict happening of a certain event, for eg. I am a cricket fan, based on today’s weather conditions like temperature and humidity levels and prior knowledge of rains happening in these conditions I would like to calculate probability if we will have a match or not, based on that I would like to place my bets :D

With this article I will try to de-mystify how a Naive Bayes Classifier works. We will proceed as :

  • Basic terminologies, events and probabilities
  • Bayes theorem, basics and formula derivation
  • Naive Bayes Classification with examples
  • Merits, Demerits and assumptions of using Naive Bayes method

Basic Definitions and terminology:

  • **Independent events: **If events take place in series in such a way that happening of first event does not impact the success/ failure of second event
  • For example: If we roll a dice 3 times and we are interested in calculating probability of getting 3 6’s in a row. It will be 1/6 * 1/6* 1/6 , first roll does not impact the probability of getting a 6 in subsequent rolls.
  • **Dependent events: **If happening of one event impacts the happening of second event then we call them dependent events
  • For example: If we draw four cards randomly without replacement from a deck of 52 cards, if we want calculate the probability of getting for queens in a row it will be 4/52 * 3/51 * 2/50 * 1/49. Here the probability of drawing a queen changes from 4/52 to 3/51 as we already removed a card and that too a queen, similarly it goes down to 1/49 in the 4th draw
  • **Conditional Probability: **When we try to calculate probability on a condition, i.e. probability of happening of event A when event B has already taken place
  • For example if we are draw 2 cards one by one without replacement from a deck and interested in calculating probability of drawing a queen the second draw when we know that first card was a queen

Equation of Conditional Probability:

Image for post

Let’s go through an example to have a clear picture.

Problem:

A purse contains 4,5 and 3 coins of denominations of Rs. 2,5 and 10 respectively. Two coins are drawn without replacing the first drawn coin . Find P( drawing Rs.2, then Rs.2)

Solution:

There are four Rs 2 coins and in total we have 12 coins so

P(Rs.2 coin in first draw) = 4/12 i.e. 1/3

The result of the first draw affected the probability of the second draw as after the first draw we are left with 3 coins of Rs.2 and in total now we have 11 coins.

P(Rs.2 coin for second draw) = 3/11

Finally P(drawing Rs. 2, then Rs 2 ) = (4/12)*(3/11) = 1/11

#predictions #data-science #towards-data-science #naive-bayes-classifier #data analysis

Conditional Probability | Bayes Theorem | Naïve Bayes Classifier
1.55 GEEK