Naive Bayes
first revise the bayse theorem:
The proof of bayse theorem
we can say probability of A given B is equal to probability of B given A into probability of A divided by probability of B.
The concept behind this algorightm
Look at this multiplication rule of independent events
For continuos attribute
so now i am going to explain every term of this formulae.
x is the feature and y is the class for eg: P(income=120 and age>13/No)
mew(u)=sample mean , sigma=sample variance xi=120 in this case don’t forget to watch example given below we will easily undetstand how things works in this algorithm.
For (Income=120k, Class=No):
Get Yahia’s stories in your inbox
Join Medium for free to get updates from this writer.
If Class=No
- sample mean = 110
• sample variance = 2975
P(Income=120K| Class=No)=( xi=120,u=mean,sigma=variance) and put it and find the probability of income =120k given class =no
Example of Naïve Bayes Classifier
naive Bayes Classifier: X (Refund No,Married,Income =120K)
P(X|Class=No) = P(Refund=No|Class=No) *P(Married| Class=No) *P(Income=120K| Class=No) = 4/7 *4/7 *0.0072 = 0.0024
P(X|Class=Yes) = P(Refund=No| Class=Yes)* P(Married| Class=Yes) *P(Income=120K| Class=Yes) = 1 *0 *1.2 *10^–9 = 0
Since
P(X|No)P(No) > P(X|Yes)P(Yes)
Therefore P(No|X) > P(Yes|X) => Class = No
Best way of solving any naive bayes ml model
so in first we are assuming play =yes and in second we are taking play=no and whoever has more probabaility we will consider as the probable outcome.
Some bonus revision
here and means you can understand intersection.







