Bayes theorem is also known as the formula for the probability of “causes”. For example: if we have to calculate the probability of taking a blue ball from the second bag out of three different bags of balls, where each bag contains three different colour balls viz. red, blue, black.
P(A|B) = P(B|A)P(A)/P(B)
Neuro-linguistic programming (NLP) problem by using Bayes Theorem
SITUATION: Generally, the word "offer" occurs in 80% of spam messages, and 10% of my desired emails.
In spam emails: 80% contain "offer" while 20% do not.
In desired emails: 10% contain "offer" while 90% do not.
QUESTION: If 30% of the received e-mails are considered as spam, and I will receive a new message which contains ‘offer’, what is the probability that it is spam?
SOLUTION:
Give an assumption first and draw a probability chart:
Received 100 emails
From the question, 30% of the emails = spam. 30=spam, 70 =desired emails.
The percentage of the word 'offer' that occurs in the spam is 80%.
80% of 30 spam email = "offer" = 24
20% of 30 spam email = Without "offer" = 6
123
The percentage of word "offer" that occurs in the desired emails is 10%
10% of 70 desired emails = "offer" = 7
63 of 70 desired emails = Without "offer"
Source: Bayes’ Theorem 101 — Example Solution | by Ezgi Gumusbas | Towards Data Science
Refer back to the question:
The question was what is the probability of spam where the mail contains the word ‘offer’:
We need to find the total number of emails which contains ‘offer’ ;
24 +7 = 31 mails containing the word ‘offer’
Find the probability of spam if the mail contains ‘offer’ ;
In 31 mails 24 contains ‘offer’ means 77.4% = 0.774 (probability)
Solution with Bayes’ Equation:
A = Spam
B = Contains the word ‘offer’
As it is seen in both ways the results are the same. In the first part, I solved the same question with a simple chart and for the second part, I solved the same question with Bayes’ theorem.