Spam No spam
“Buy”
Spam Detector
Quiz: If an e-mail
contains the word “buy”,
what is the probability
that it is spam?
Spam No spam
“Buy”
Spam Detector
40%Quiz: If an e-mail
contains the word “buy”,
what is the probability
that it is spam?
Spam No spam
“Buy”
Spam Detector
60%
40%Quiz: If an e-mail
contains the word “buy”,
what is the probability
that it is spam?
Spam No spam
“Buy”
Spam Detector
60%
80%
40%Quiz: If an e-mail
contains the word “buy”,
what is the probability
that it is spam?
Spam No spam
“Buy”
Spam Detector
60%
80%
40%Quiz: If an e-mail
contains the word “buy”,
what is the probability
that it is spam?
100%
Spam No spam
“Buy”
Spam Detector
20
60%
80%
40%Quiz: If an e-mail
contains the word “buy”,
what is the probability
that it is spam?
100%
Spam No spam
“Buy”
Spam Detector
20 5
60%
80%
40%Quiz: If an e-mail
contains the word “buy”,
what is the probability
that it is spam?
100%
Spam No spam
“Buy”
Spam Detector
20 580% 20%
60%
80%
40%Quiz: If an e-mail
contains the word “buy”,
what is the probability
that it is spam?
100%
Spam No spam
“Buy”
Spam Detector
20 580% 20%
60%
80%
40%Quiz: If an e-mail
contains the word “buy”,
what is the probability
that it is spam?
100%
Spam No spam
“Buy”
Spam Detector
20 580% 20%
60%
Solution:
80%
80%
40%Quiz: If an e-mail
contains the word “buy”,
what is the probability
that it is spam?
100%
Spam No spam
“Buy”
Spam Detector
20 580% 20%
60%
Solution:
80%
80%
40%Quiz: If an e-mail
contains the word “buy”,
what is the probability
that it is spam?
100%
Spam No spam
“Buy”
Spam Detector
20 580% 20%
60%
Solution:
80%
80%
40%Quiz: If an e-mail
contains the word “buy”,
what is the probability
that it is spam?
100%
80%
Spam No spam
“Buy”
20 580% 20%
60%
Solution:
80%
80%
40%Quiz: If an e-mail
contains the word “buy”,
what is the probability
that it is spam?
100%
80%
Bayes Theorem
Spam No spam
“Buy” and “Cheap”
Quiz: If an e-mail
contains the words “buy”
and “cheap”, what is the
probability that it is
spam?
Spam Detector
Spam No spam
“Buy” and “Cheap”
40%Quiz: If an e-mail
contains the words “buy”
and “cheap”, what is the
probability that it is
spam?
Spam Detector
Spam No spam
“Buy” and “Cheap”
60%
40%Quiz: If an e-mail
contains the words “buy”
and “cheap”, what is the
probability that it is
spam?
Spam Detector
Spam No spam
“Buy” and “Cheap”
60%
80%
40%Quiz: If an e-mail
contains the words “buy”
and “cheap”, what is the
probability that it is
spam?
Spam Detector
Spam No spam
“Buy” and “Cheap”
60%
80%
40%Quiz: If an e-mail
contains the words “buy”
and “cheap”, what is the
probability that it is
spam?
100%
Spam Detector
Spam No spam
“Buy” and “Cheap”
60%
80%
40%Quiz: If an e-mail
contains the words “buy”
and “cheap”, what is the
probability that it is
spam?
100%
Spam Detector
Spam No spam
“Buy” and “Cheap”
12
60%
80%
40%Quiz: If an e-mail
contains the words “buy”
and “cheap”, what is the
probability that it is
spam?
100%
Spam Detector
Spam No spam
“Buy” and “Cheap”
12
60%
80%
40%Quiz: If an e-mail
contains the words “buy”
and “cheap”, what is the
probability that it is
spam?
100%
Spam Detector
Spam No spam
“Buy” and “Cheap”
012
60%
80%
40%Quiz: If an e-mail
contains the words “buy”
and “cheap”, what is the
probability that it is
spam?
100%
Spam Detector
Spam No spam
“Buy” and “Cheap”
00%12100%
60%
80%
40%Quiz: If an e-mail
contains the words “buy”
and “cheap”, what is the
probability that it is
spam?
100%
Spam Detector
Spam No spam
“Buy” and “Cheap”
00%12100%
60%
80%
40%Quiz: If an e-mail
contains the words “buy”
and “cheap”, what is the
probability that it is
spam?
100%
Spam Detector
Spam No spam
“Buy” and “Cheap”
00%12100%
60%
Solution:
100%
80%
40%Quiz: If an e-mail
contains the words “buy”
and “cheap”, what is the
probability that it is
spam?
100%
Spam Detector
Spam No spam
“Buy” and “Cheap”
00%12100%
60%
Solution:
100%
80%
40%Quiz: If an e-mail
contains the words “buy”
and “cheap”, what is the
probability that it is
spam?
100%
Spam Detector
Spam No spam
“Buy” and “Cheap”
00%12100%
60%
Solution:
100%
80%
40%Quiz: If an e-mail
contains the words “buy”
and “cheap”, what is the
probability that it is
spam?
100%
100% ?
Spam Detector
Spam No spam
Spam Detector
“Buy” and “Cheap”
12 2/3
Quiz: If an e-mail
contains the words “buy”
and “cheap”, what is the
probability that it is
spam?
12 2/312
Spam No spam
Spam Detector
“Buy” and “Cheap”
12 2/3
Quiz: If an e-mail
contains the words “buy”
and “cheap”, what is the
probability that it is
spam?
12
2/312
Spam No spam
Spam Detector
“Buy” and “Cheap”
12 2/3
Quiz: If an e-mail
contains the words “buy”
and “cheap”, what is the
probability that it is
spam?
12
2/31212 + 2/3
12
Spam No spam
Spam Detector
“Buy” and “Cheap”
12 2/3
=
38
36
Quiz: If an e-mail
contains the words “buy”
and “cheap”, what is the
probability that it is
spam?
12
2/31212 + 2/3
12
Spam No spam
Spam Detector
“Buy” and “Cheap”
12 2/3
=
38
36
= 94.737%
Quiz: If an e-mail
contains the words “buy”
and “cheap”, what is the
probability that it is
spam?
12
2/31212 + 2/3
12
Spam No spam
Spam Detector
“Buy” and “Cheap”
12 2/3
=
38
36
= 94.737%
94.737%
Quiz: If an e-mail
contains the words “buy”
and “cheap”, what is the
probability that it is
spam?
12
2/31212 + 2/3
12
Spam No spam
Spam Detector
“Buy” and “Cheap”
12 2/3
5.263% =
38
36
= 94.737%
94.737%
Quiz: If an e-mail
contains the words “buy”
and “cheap”, what is the
probability that it is
spam?
12
2/31212 + 2/3
12
Spam No spam
Spam Detector
“Buy” and “Cheap”
12 2/3
5.263% =
38
36
= 94.737%
94.737%
Quiz: If an e-mail
contains the words “buy”
and “cheap”, what is the
probability that it is
spam?
12
2/31212 + 2/3
12
94.737%
Spam No spam
“Buy” and “Cheap”
12 2/3
5.263% =
38
36
= 94.737%
94.737%
Quiz: If an e-mail
contains the words “buy”
and “cheap”, what is the
probability that it is
spam?
12
2/31212 + 2/3
12
Naive Bayes Classifier
94.737%
P(“Buy” & “Cheap”) = P(“Buy”) P(“Cheap”)
Naive
P(B C) = P(B) P(C)
U
Naive Bayes
Naive BayesS: Spam
H: Ham (not spam)
B: ‘Buy’
C: ‘Cheap’
P(S B C) =
P(S)
P(S) + P(H)
U P(B C S)
U
P(B C S)
U
P(B C H)
U
P(B S)P(C S)
P(B S)P(C S) P(B H)P(C H)
Naive BayesS: Spam
H: Ham (not spam)
B: ‘Buy’
C: ‘Cheap’
P(S B C) =
P(S)
P(S) + P(H)
U P(B C S)
U
P(B C S)
U
P(B C H)
U
P(B S)P(C S)
P(B S)P(C S) P(B H)P(C H)
P(spam if “Buy” & “Cheap”) =
Naive BayesS: Spam
H: Ham (not spam)
B: ‘Buy’
C: ‘Cheap’
P(S B C) =
P(S)
P(S) + P(H)
U P(B C S)
U
P(B C S)
U
P(B C H)
U
P(B S)P(C S)
P(B S)P(C S) P(B H)P(C H)
P(spam if “Buy” & “Cheap”) =
Naive BayesS: Spam
H: Ham (not spam)
B: ‘Buy’
C: ‘Cheap’
P(S B C) =
P(S)
P(S) + P(H)
U P(B C S)
U
P(B C S)
U
P(B C H)
U
P(B S)P(C S)
P(B S)P(C S) P(B H)P(C H)
P(spam if “Buy” & “Cheap”) =
20
25
Naive BayesS: Spam
H: Ham (not spam)
B: ‘Buy’
C: ‘Cheap’
P(S B C) =
P(S)
P(S) + P(H)
U P(B C S)
U
P(B C S)
U
P(B C H)
U
P(B S)P(C S)
P(B S)P(C S) P(B H)P(C H)
P(spam if “Buy” & “Cheap”) =
20
25
15
25
Naive BayesS: Spam
H: Ham (not spam)
B: ‘Buy’
C: ‘Cheap’
P(S B C) =
P(S)
P(S) + P(H)
U P(B C S)
U
P(B C S)
U
P(B C H)
U
P(B S)P(C S)
P(B S)P(C S) P(B H)P(C H)
P(spam if “Buy” & “Cheap”) =
20
25
25
100
15
25
Naive BayesS: Spam
H: Ham (not spam)
B: ‘Buy’
C: ‘Cheap’
P(S B C) =
P(S)
P(S) + P(H)
U P(B C S)
U
P(B C S)
U
P(B C H)
U
P(B S)P(C S)
P(B S)P(C S) P(B H)P(C H)
P(spam if “Buy” & “Cheap”) =
20
25
25
100
20
25
15
25
Naive BayesS: Spam
H: Ham (not spam)
B: ‘Buy’
C: ‘Cheap’
P(S B C) =
P(S)
P(S) + P(H)
U P(B C S)
U
P(B C S)
U
P(B C H)
U
P(B S)P(C S)
P(B S)P(C S) P(B H)P(C H)
P(spam if “Buy” & “Cheap”) =
20
25
25
100
20
25
15
25
15
25
Naive BayesS: Spam
H: Ham (not spam)
B: ‘Buy’
C: ‘Cheap’
P(S B C) =
P(S)
P(S) + P(H)
U P(B C S)
U
P(B C S)
U
P(B C H)
U
P(B S)P(C S)
P(B S)P(C S) P(B H)P(C H)
P(spam if “Buy” & “Cheap”) =
20
25
25
100
20
25
25
100
15
25
15
25
Naive BayesS: Spam
H: Ham (not spam)
B: ‘Buy’
C: ‘Cheap’
P(S B C) =
P(S)
P(S) + P(H)
U P(B C S)
U
P(B C S)
U
P(B C H)
U
P(B S)P(C S)
P(B S)P(C S) P(B H)P(C H)
P(spam if “Buy” & “Cheap”) =
20
25
25
100
20
25
25
100
+
15
25
15
25
Naive BayesS: Spam
H: Ham (not spam)
B: ‘Buy’
C: ‘Cheap’
P(S B C) =
P(S)
P(S) + P(H)
U P(B C S)
U
P(B C S)
U
P(B C H)
U
P(B S)P(C S)
P(B S)P(C S) P(B H)P(C H)
P(spam if “Buy” & “Cheap”) =
20
25
25
100
20
25
25
100
5
75
+
15
25
15
25
Naive BayesS: Spam
H: Ham (not spam)
B: ‘Buy’
C: ‘Cheap’
P(S B C) =
P(S)
P(S) + P(H)
U P(B C S)
U
P(B C S)
U
P(B C H)
U
P(B S)P(C S)
P(B S)P(C S) P(B H)P(C H)
P(spam if “Buy” & “Cheap”) =
20
25
25
100
20
25
25
100
5
75
+
15
25
15
25
10
75
Naive BayesS: Spam
H: Ham (not spam)
B: ‘Buy’
C: ‘Cheap’
P(S B C) =
P(S)
P(S) + P(H)
U P(B C S)
U
P(B C S)
U
P(B C H)
U
P(B S)P(C S)
P(B S)P(C S) P(B H)P(C H)
P(spam if “Buy” & “Cheap”) =
20
25
25
100
20
25
25
100
5
75
75
100
+
15
25
15
25
10
75
= 94.737%
Naive BayesS: Spam
H: Ham (not spam)
B: ‘Buy’
C: ‘Cheap’
P(S B C) =
P(S)
P(S) + P(H)
U P(B C S)
U
P(B C S)
U
P(B C H)
U
P(B S)P(C S)
P(B S)P(C S) P(B H)P(C H)
P(spam if “Buy” & “Cheap”) =
20
25
25
100
20
25
25
100
5
75
75
100
+
15
25
15
25
10
75