Bayesian Statistics

Bayes Theorem

Bayes’ theorem is so fundamental and ubiquitous that a field called “bayesian statistics” exists.

In bayesian statistics, the probability of an event or hypothesis as evidence comes into play.

Therefore, prior probabilities and posterior probabilities differ depending on the evidence.

Bayes’ Theorem

P(AB)=P(BA)×P(A)P(B)P(A|B)=\frac{P(B|A) \times P(A)}{P(B)}

P(A|B) = Posterior probability of “A” (the hypothesis) given the evidence “B” P(B|A) = Likelihood of the evidence “B” given the hypothesis “A” is true P(A) = Prior probability (The marginal probability of the event “A”) P(B) = Prior probability that the evidence itself is true

P(HE)=P(EH)×P(H)P(E)P(H|E)=\frac{P(E|H) \times P(H)}{P(E)}

Example

Team A and Team B have played each other 10 times, and Team A has won 9 of those times. If the teams are playing each other tonight, and I ask you who you think will win, you’d probably say Team A! What if I also told you that Team B has bribed tonight’s referees? Well, then you might guess that Team B will win.

Bayesian statistics allows you to incorporate this extra information into your calculations, while frequentist statistics focuses solely on the 9 out of 10 win percentage.

The conditional probability of H given E, written P(HE)P(H|E), represents the probability of H occurring given that E also occurs (or has occurred). In our example, H is the hypothesis that Team B will win, and E is the evidence that I gave you about Team B bribing the referees.

P(H)P(H) is the frequentist probability, 10%. P(EH)P( E|H) is the probability that what I told you about the bribe is true, given that Team B wins. (If Team B wins tonight, would you believe what I told you?)

Finally, P(E)P( E) is the probability that Team B has in fact bribed the referees. Am I a trustworthy source of information? You can see that this approach incorporates more information than just the outcomes of the two teams’ previous 10 match-ups.

Bayes Theorem to Naive Bayes Classifier

Naive bayes algorithm is structured by combining bayes’ theorem and some naive assumptions. Naive bayes algorithm assumes that features are independent of each other and there is no correlation between features.

The direct application of Bayes Theorem for classification becomes intractable, especially as the number of variables or features (n) increases. Instead, we can simplify the calculation and assume that each input variable is independent.

Although dramatic, this simpler calculation often gives very good performance, even when the input variables are highly dependent.

We can implement this from scratch by assuming a probability distribution for each separate input variable and calculating the probability of each specific input value belonging to each class and multiply the results together to give a score used to select the most likely class.

P(yix1,x2,...xn)=P(x1y1)P(x2y1)...P(xny1)P(y1)P(yi|x1,x2,...xn) = P(x1|y1)*P(x2|y1)...P(xn|y1)*P(y1)

Last updated