All about Bayes Theorem!

Original article was published on Deep Learning on Medium

Ever wondered about calculating the probability of an event based on some other event, it would have been fun right! If till now you have not figured out trying the above scenario, I will help you and explain what how it is possible and also it is too much fun.

In mathematics world, if we are trying to find out the probability of an event based on occurrence of another event, we denote it with “|” symbol between the two events. For Example, P(Happy | Watched a movie), where “P” represent Probability and the inner two are events, and the above equation signifies the probability of a person being happy given that he/she has watched a movie[I have taken this example in context with a person].

Bayes Theorem Equation

In the given image above, “A” & “B” are events, and in order to find the probability of occurrence of event “A” given that event “B” has already occurred, is calculated by the above equation, where “P” always represents “probability.”

Bayes Theorem is based on the 4 concepts, those are “Likelihood”, “Prior Probability”, “Marginal Probability”, & “Posterior Probability”, which are also listed in the image below.

Prior Probability

It signifies the probability of the occurrence of an event(our hypothesis) before the occurrence of another event or we can say before observing the evidence.

Marginal Probability

It signifies the probability of the occurrence of an event(actual event/evidence or the event which we are considering to be already occurred) to occur in all the possibilities of our hypothesis.

Likelihood

It signifies the probability of an event to be true/ or to occur, if we consider our hypothesis to be true, or we can say that another event(out hypothesis) has already been occurred.

Posterior Probability

It signifies the probability of occurrence of an event (our hypothesis) given that another event has already been occurred.

Now, if we have the first 3 parameters from the above list of 4 parameters, we can easily predict the final one using the Bayes Theorem.

Example:

Consider that we have to find the probability for a person to be happy after it has watched a movie.

Consider the below given probabilities initially:

  1. P(Happy) = 0.9
  2. P(Watch a movie) = 0.95
  3. P(Watch a movie | Happy) = 0.5 < = it means that a person will watch a movie if it is happy.

Now, we have to calculate P(Happy | Watch a movie)

Using Bayes Theorem on the above situation, we can definitely calculate our desired outcome.

P(Happy | Watch a Movie) = [ P(Watch a Movie | Happy) * P(Happy) ] / P(Watch a Movie)

P(Happy | Watch a Movie) = (0.5 * 0.9) / (0.95) = 0.4736

Above is the probability calculated for a person which is happy after watching a movie according to the above data.