The Bayes theorem helps us in finding posterior probability, given a certain condition:
P(A|B)= P(B|A) * P(A)/P(B)
A and B can be deemed as the target and features, respectively.
Where, P(A|B): posterior probability, which implies the probability of event A, given that B has taken place:
- P(B|A): The likelihood that implies the probability of feature B, given the target A
- P(A): The prior probability of target A
- P(B): The prior probability of feature B
We will try to understand all of this by looking at the example of the Titanic. While the Titanic was sinking, a few of the categories had priority over others, in terms of being saved. We have the following dataset (it is a Kaggle dataset):
Person category | Survival chance |
Woman | Yes |
Kid | Yes |
Kid | Yes |
Man | No |
Woman | Yes |
Woman | Yes |
Man | No |
Man | Yes |
Kid | Yes |
Woman | No |
Kid | No |
Woman | No |
Man | Yes |
Man | No |
Woman | Yes |
Now, let's prepare a likelihood table for the preceding information:
|
| Survival chance |
|
|
| |
| No | Yes | Grand Total |
|
| |
Category | Kid | 1 | 3 | 4 | 4/15= | 0.27 |
Man... |