naive_bayes
naive_bayes
Bayes
Theorem
Feature
Independence
Assumption
Probability of Event
Probability is measure of how
likely an event is
# ways for A
P(A) =
# possible outcomes
Probability of Event
What is the probability of rolling a
die and getting 6?
P(A) P(B)
P(A,B)
1 1 1
P(A,B) = P(A) * P(B) = * =
6 6 36
Conditional Probability
Probability of event A
P(A) P(B) occurring, given that
event B occurred
P(A,B)
P(A,B) Conditional
P(A | B) =
P(B) Probability
Bayes’ Theorem
• Relationship between P(B | A) and P(A | B)
can be expressed through Bayes’ Theorem
P(A | B) * P(B)
P(B | A) =
P(A)
Bayes’ Theorem
Classification with Probabilities
Given features X={X1,X2,…,Xn}, predict class C
Do this by finding value of C that maximizes P(C | X)
P(C1|X)
P(C2|X)
. max
Class
. Label
.
P(Ck|X)
Bayes’ Theorem for Classification
• But estimating P(C|X) is difficult
• Bayes’ Theorem to the rescue!
• Simplifies problem
Bayes’ Theorem for Classification
Class-
Posterior Conditional Prior
Probability Probability Probability
P(X | C) * P(C)
P(C | X) =
P(X)
Probability of observing
values for input features
Bayes’ Theorem for Classification
Need to
Can be estimated from data!
calculate this
P(X | C) * P(C)
P(C | X) =
P(X)
P( ) = 4/10 = 0.4
P( ) = 6/10 = 0.6
Bayes
Theorem
Feature
Independence
Assumption