11. Spam No spam
“Buy”
Spam Detector
Quiz: If an e-mail
contains the word “buy”,
what is the probability
that it is spam?
12. Spam No spam
“Buy”
Spam Detector
40%Quiz: If an e-mail
contains the word “buy”,
what is the probability
that it is spam?
13. 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?
14. 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?
15. 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%
16. 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%
17. 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%
18. 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%
19. 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%
20. 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%
21. 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%
22. 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%
23. 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
39. Spam No spam
“Cheap”
60%
80%
40%Quiz: If an e-mail
contains the word
“cheap”, what is the
probability that it is
spam?
15 1060% 40%
100%
Bayes Theorem
51. 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
52. 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
53. 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
54. 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
55. 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
56. 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
57. 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
58. 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
59. 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
60. 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
61. 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
62. 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
63. 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
64. 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
111. 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
112. 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
113. 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
114. 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
115. 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
116. 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
117. 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
118. 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%
119. 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%
189. P(“Buy” & “Cheap”) = P(“Buy”) P(“Cheap”)
P(B C) = P(B) P(C)
U
Naive Bayes
190. P(“Buy” & “Cheap”) = P(“Buy”) P(“Cheap”)
Naive
P(B C) = P(B) P(C)
U
Naive Bayes
191. 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)
192. 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”) =
193. 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”) =
194. 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
195. 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
196. 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
197. 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
198. 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
199. 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
200. 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
201. 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
202. 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
203. 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
204. = 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