Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Bayes theorem and Naive Bayes algorithm

12 views

Published on

Slides for this YouTube video
https://www.youtube.com/watch?v=Q8l0Vip5YUw

Published in: Science
  • Be the first to comment

  • Be the first to like this

Bayes theorem and Naive Bayes algorithm

  1. 1. Naive Bayes
  2. 2. Luis Serrano Naive Bayes Classifier
  3. 3. Bayes Theorem P(A B) = P(B A) P(B A) P(A) P(A)+ P(B Ac )P(Ac )
  4. 4. 3. Bayes Theorem
  5. 5. Spam Detector 100 e-mails
  6. 6. Spam No spam Spam Detector 25 75
  7. 7. Spam No spam “Buy” Spam Detector 25 75
  8. 8. Spam No spam “Buy” Spam Detector 25 75
  9. 9. Spam No spam “Buy” Spam Detector 25 75
  10. 10. Spam No spam “Buy” Spam Detector
  11. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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
  24. 24. Spam No spam Spam Detector
  25. 25. Spam No spam Spam Detector “Cheap”
  26. 26. Spam No spam Spam Detector “Cheap”
  27. 27. Spam No spam Spam Detector “Cheap”
  28. 28. Spam No spam “Cheap” Bayes Theorem
  29. 29. Spam No spam “Cheap” Quiz: If an e-mail contains the word “cheap”, what is the probability that it is spam? Bayes Theorem
  30. 30. Spam No spam “Cheap” 40%Quiz: If an e-mail contains the word “cheap”, what is the probability that it is spam? Bayes Theorem
  31. 31. Spam No spam “Cheap” 60% 40%Quiz: If an e-mail contains the word “cheap”, what is the probability that it is spam? Bayes Theorem
  32. 32. Spam No spam “Cheap” 60% 80% 40%Quiz: If an e-mail contains the word “cheap”, what is the probability that it is spam? Bayes Theorem
  33. 33. Spam No spam “Cheap” 60% 80% 40%Quiz: If an e-mail contains the word “cheap”, what is the probability that it is spam? 100% Bayes Theorem
  34. 34. Spam No spam “Cheap” 60% 80% 40%Quiz: If an e-mail contains the word “cheap”, what is the probability that it is spam? 100% Bayes Theorem
  35. 35. Spam No spam “Cheap” 60% 80% 40%Quiz: If an e-mail contains the word “cheap”, what is the probability that it is spam? 100% Bayes Theorem
  36. 36. Spam No spam “Cheap” 60% 80% 40%Quiz: If an e-mail contains the word “cheap”, what is the probability that it is spam? 100% Bayes Theorem
  37. 37. 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 100% Bayes Theorem
  38. 38. 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 10 100% Bayes Theorem
  39. 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
  40. 40. Spam No spam “Cheap” 60% Solution: 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
  41. 41. Spam No spam “Cheap” 60% Solution: 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
  42. 42. Spam No spam “Cheap” 60% Solution: 60% 80% 40%Quiz: If an e-mail contains the word “cheap”, what is the probability that it is spam? 15 1060% 40% 100% 60% Bayes Theorem
  43. 43. Spam No spam Spam Detector “Buy” and “Cheap”
  44. 44. Spam No spam Spam Detector “Buy” and “Cheap”
  45. 45. Spam No spam Spam Detector “Buy” and “Cheap”
  46. 46. Spam No spam Spam Detector “Buy” and “Cheap”
  47. 47. Spam No spam Spam Detector “Buy” and “Cheap”
  48. 48. Spam No spam Spam Detector “Buy” and “Cheap”
  49. 49. Spam No spam Spam Detector “Buy” and “Cheap”
  50. 50. Spam No spam “Buy” and “Cheap” Spam Detector
  51. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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
  65. 65. Problem Spam No spam “Buy” and “Cheap”
  66. 66. Problem Spam No spam “Buy” and “Cheap” 12 e-mails
  67. 67. Problem Spam No spam “Buy” and “Cheap” 12 e-mails 0 e-mails?
  68. 68. Solution: Collect more data?
  69. 69. Solution: Collect more data?
  70. 70. Solution: Collect more data?
  71. 71. Spam Detector Spam No spam “Buy” and “Cheap” 12 e-mails 0 e-mails?
  72. 72. Spam Detector Spam No spam “Buy” and “Cheap” 12 e-mails 0 e-mails? Guess?
  73. 73. Spam Detector
  74. 74. Spam Detector 100 e-mails
  75. 75. Spam Detector 100 e-mails 5 “Buy”
  76. 76. Spam Detector 100 e-mails 5 “Buy”
  77. 77. Spam Detector 100 e-mails 5 “Buy” 10 “Cheap”
  78. 78. Spam Detector 100 e-mails 5 “Buy” 10 “Cheap”
  79. 79. Spam Detector 100 e-mails 5 “Buy” 10 “Cheap” 5% “Buy”
  80. 80. Spam Detector 100 e-mails 5 “Buy” 10 “Cheap” 5% “Buy” 10% “Cheap”
  81. 81. Spam Detector 100 e-mails 5 “Buy” 10 “Cheap” 5% “Buy” 10% “Cheap”
  82. 82. Spam Detector 100 e-mails 5 “Buy” 10 “Cheap” 5% “Buy” 10% “Cheap” 0.5% “Buy” and “Cheap”
  83. 83. Spam Detector 100 e-mails 5 “Buy” 10 “Cheap” 5% “Buy” 10% “Cheap” 0.5% “Buy” and “Cheap”
  84. 84. Spam Detector 100 e-mails 5 “Buy” 10 “Cheap” 5% “Buy” 10% “Cheap” 0.5% “Buy” and “Cheap” Independent
  85. 85. Spam Detector 100 e-mails 5 “Buy” 10 “Cheap” 5% “Buy” 10% “Cheap” 0.5% “Buy” and “Cheap” Independent That’s naive!
  86. 86. Spam Spam Detector
  87. 87. Spam Spam Detector 25 e-mails
  88. 88. Spam Spam Detector 25 e-mails
  89. 89. Spam Spam Detector 25 e-mails 20 “Buy”
  90. 90. Spam Spam Detector 25 e-mails 20 “Buy” 4/5
  91. 91. Spam Spam Detector 25 e-mails 20 “Buy” 4/5
  92. 92. Spam Spam Detector 25 e-mails 20 “Buy” 15 Cheap 4/5
  93. 93. Spam Spam Detector 25 e-mails 20 “Buy” 15 Cheap 4/5 3/5
  94. 94. Spam Spam Detector 25 e-mails 20 “Buy” 15 Cheap 4/5 3/5
  95. 95. Spam Spam Detector 25 e-mails 20 “Buy” 15 Cheap 4/5 3/5 12/25
  96. 96. Spam Spam Detector 25 e-mails 20 “Buy” 15 Cheap 4/5 3/5 12/25 x 25
  97. 97. Spam Spam Detector 25 e-mails 20 “Buy” 15 Cheap 4/5 3/5 12/25 = 12 “Buy” and “Cheap”x 25
  98. 98. Spam Spam Detector 25 e-mails 20 “Buy” 15 Cheap 4/5 3/5 12/25 = 12 “Buy” and “Cheap”x 25
  99. 99. No spam Spam Detector
  100. 100. No spam Spam Detector 75 e-mails
  101. 101. No spam Spam Detector 75 e-mails 5 “Buy”
  102. 102. No spam Spam Detector 75 e-mails 5 “Buy” 1/15
  103. 103. No spam Spam Detector 75 e-mails 5 “Buy” 10 “Cheap” 1/15
  104. 104. No spam Spam Detector 75 e-mails 5 “Buy” 10 “Cheap” 1/15 2/15
  105. 105. No spam Spam Detector 75 e-mails 5 “Buy” 10 “Cheap” 1/15 2/15 2/225
  106. 106. No spam Spam Detector 75 e-mails 5 “Buy” 10 “Cheap” 1/15 2/15 2/225 x 75
  107. 107. No spam Spam Detector 75 e-mails 5 “Buy” 10 “Cheap” 1/15 2/15 2/225 = 2/3 “Buy” and “Cheap”x 75
  108. 108. No spam Spam Detector 75 e-mails 5 “Buy” 10 “Cheap” 1/15 2/15 2/225 = 2/3 “Buy” and “Cheap”x 75
  109. 109. Spam No spam Spam Detector “Buy” and “Cheap” 12 2/3
  110. 110. Spam No spam Spam Detector “Buy” and “Cheap” 12 2/3
  111. 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. 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. 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. 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. 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. 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. 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. 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. 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%
  120. 120. Naive Bayes Spam No spam
  121. 121. Total Buy Cheap Buy & Cheap Naive Bayes Spam No spam
  122. 122. Total Buy Cheap Buy & Cheap 25 Naive Bayes Spam No spam
  123. 123. Total Buy Cheap Buy & Cheap 25 75 Naive Bayes Spam No spam
  124. 124. Total Buy Cheap Buy & Cheap 25 75 20 Naive Bayes Spam No spam
  125. 125. Total Buy Cheap Buy & Cheap 25 75 20 4/5 Naive Bayes Spam No spam
  126. 126. Total Buy Cheap Buy & Cheap 25 75 20 4/5 5 Naive Bayes Spam No spam
  127. 127. Total Buy Cheap Buy & Cheap 25 75 20 4/5 5 1/15 Naive Bayes Spam No spam
  128. 128. Total Buy Cheap Buy & Cheap 25 75 20 15 4/5 5 1/15 Naive Bayes Spam No spam
  129. 129. Total Buy Cheap Buy & Cheap 25 75 20 15 4/5 3/5 5 1/15 Naive Bayes Spam No spam
  130. 130. Total Buy Cheap Buy & Cheap 25 75 20 15 4/5 3/5 5 10 1/15 Naive Bayes Spam No spam
  131. 131. Total Buy Cheap Buy & Cheap 25 75 20 15 4/5 3/5 5 10 1/15 2/15 Naive Bayes Spam No spam
  132. 132. Total Buy Cheap Buy & Cheap 25 75 20 15 4/5 3/5 5 10 1/15 2/15 Naive Bayes Spam No spam
  133. 133. Total Buy Cheap Buy & Cheap 25 75 20 15 4/5 3/5 12/25 5 10 1/15 2/15 Naive Bayes Spam No spam
  134. 134. Total Buy Cheap Buy & Cheap 25 75 20 15 4/5 3/5 12/25 5 10 1/15 2/15 Naive Bayes Spam No spam
  135. 135. Total Buy Cheap Buy & Cheap 25 75 20 15 4/5 3/5 12/25 5 10 1/15 2/15 Naive Bayes Spam No spam
  136. 136. Total Buy Cheap Buy & Cheap 25 75 20 15 4/5 3/5 12/25 5 10 1/15 2/15 Naive Bayes Spam No spam
  137. 137. Total Buy Cheap Buy & Cheap 25 75 20 15 12 4/5 3/5 12/25 5 10 1/15 2/15 Naive Bayes Spam No spam
  138. 138. Total Buy Cheap Buy & Cheap 25 75 20 15 12 4/5 3/5 12/25 5 10 1/15 2/15 Naive Bayes Spam No spam
  139. 139. Total Buy Cheap Buy & Cheap 25 75 20 15 12 4/5 3/5 12/25 5 10 1/15 2/15 Naive Bayes Spam No spam
  140. 140. Total Buy Cheap Buy & Cheap 25 75 20 15 12 4/5 3/5 12/25 5 10 1/15 2/15 2/225 Naive Bayes Spam No spam
  141. 141. Total Buy Cheap Buy & Cheap 25 75 20 15 12 4/5 3/5 12/25 5 10 1/15 2/15 2/225 Naive Bayes Spam No spam
  142. 142. Total Buy Cheap Buy & Cheap 25 75 20 15 12 4/5 3/5 12/25 5 10 1/15 2/15 2/225 Naive Bayes Spam No spam
  143. 143. Total Buy Cheap Buy & Cheap 25 75 20 15 12 4/5 3/5 12/25 5 10 1/15 2/15 2/225 Naive Bayes Spam No spam
  144. 144. Total Buy Cheap Buy & Cheap 25 75 20 15 12 4/5 3/5 12/25 5 10 2/3 1/15 2/15 2/225 Naive Bayes Spam No spam
  145. 145. Total Buy Cheap Buy & Cheap 25 75 20 15 12 4/5 3/5 12/25 5 10 2/3 1/15 2/15 2/225 Naive Bayes Spam No spam
  146. 146. Total Buy Cheap Buy & Cheap 25 75 20 15 12 4/5 3/5 12/25 5 10 2/3 1/15 2/15 2/225 Naive Bayes Spam No spam
  147. 147. Total Buy Cheap Buy & Cheap 25 75 20 15 12 4/5 3/5 12/25 5 10 2/3 1/15 2/15 2/225 Naive Bayes Spam No spam
  148. 148. Total Buy Cheap Buy & Cheap 25 75 20 15 12 4/5 3/5 12/25 5 10 2/3 1/15 2/15 2/225 12 + 2/3 12 Naive Bayes Spam No spam
  149. 149. Total Buy Cheap Buy & Cheap 25 75 20 15 12 4/5 3/5 12/25 5 10 2/3 1/15 2/15 2/225 = 38 36 12 + 2/3 12 Naive Bayes Spam No spam
  150. 150. Total Buy Cheap Buy & Cheap 25 75 20 15 12 4/5 3/5 12/25 5 10 2/3 1/15 2/15 2/225 = 38 36 = 94.737% 12 + 2/3 12 Naive Bayes Spam No spam
  151. 151. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 Naive Bayes
  152. 152. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 5 Naive Bayes
  153. 153. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 5 30 Naive Bayes
  154. 154. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 5 1/5 30 Naive Bayes
  155. 155. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 5 1/5 30 6/15 Naive Bayes
  156. 156. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 5 1/5 30 6/15 Naive Bayes
  157. 157. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 5 1/5 30 6/15 12/125 Naive Bayes
  158. 158. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 5 1/5 30 6/15 12/125 Naive Bayes
  159. 159. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 5 1/5 30 6/15 12/125 Naive Bayes
  160. 160. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 5 1/5 30 6/15 12/125 Naive Bayes
  161. 161. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 5 1/5 30 6/15 12/5 12/125 Naive Bayes
  162. 162. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 5 1/5 30 6/15 12/5 12/125 Naive Bayes
  163. 163. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 5 1/5 30 6/15 12/5 12/125 Naive Bayes
  164. 164. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 5 1/5 30 6/15 12/5 12/125 12/3375 Naive Bayes
  165. 165. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 5 1/5 30 6/15 12/5 12/125 12/3375 Naive Bayes
  166. 166. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 5 1/5 30 6/15 12/5 12/125 12/3375 Naive Bayes
  167. 167. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 5 1/5 30 6/15 12/5 12/125 12/3375 Naive Bayes
  168. 168. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 5 1/5 30 6/15 12/5 12/125 4/15 12/3375 Naive Bayes
  169. 169. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 5 1/5 30 6/15 12/5 12/125 4/15 12/3375 Naive Bayes
  170. 170. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 5 1/5 30 6/15 12/5 12/125 4/15 12/3375 Naive Bayes
  171. 171. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 5 1/5 30 6/15 12/5 12/125 4/15 12/3375 Naive Bayes
  172. 172. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 5 1/5 30 6/15 12/5 + 4/15 12/5 12/5 12/125 4/15 12/3375 Naive Bayes
  173. 173. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 5 1/5 30 6/15 = 40 36 12/5 + 4/15 12/5 12/5 12/125 4/15 12/3375 Naive Bayes
  174. 174. Total Buy 20 4/5 5 1/15 Cheap 15 3/5 10 2/15 Work Buy, Cheap, & Work Spam No Spam 25 75 5 1/5 30 6/15 = 40 36 = 90% 12/5 + 4/15 12/5 12/5 12/125 4/15 12/3375 Naive Bayes
  175. 175. 4. The math
  176. 176. Bayes Theorem P(S B) = P(B S) P(B S) P(S) P(S)+P(B H)P(H) S: Spam H: Ham (not spam) B: ‘Buy’
  177. 177. Bayes Theorem P(S B) = P(B S) P(B S) P(S) P(S)+P(B H)P(H) S: Spam H: Ham (not spam) B: ‘Buy’ P(spam if “Buy”) =
  178. 178. Bayes Theorem P(S B) = P(B S) P(B S) P(S) P(S)+P(B H)P(H) S: Spam H: Ham (not spam) B: ‘Buy’ P(spam if “Buy”) =
  179. 179. Bayes Theorem P(S B) = P(B S) P(B S) P(S) P(S)+P(B H)P(H) S: Spam H: Ham (not spam) B: ‘Buy’ P(spam if “Buy”) = 20 25
  180. 180. Bayes Theorem P(S B) = P(B S) P(B S) P(S) P(S)+P(B H)P(H) S: Spam H: Ham (not spam) B: ‘Buy’ P(spam if “Buy”) = 20 25 25 100
  181. 181. Bayes Theorem P(S B) = P(B S) P(B S) P(S) P(S)+P(B H)P(H) S: Spam H: Ham (not spam) B: ‘Buy’ P(spam if “Buy”) = 20 25 25 100 20 25
  182. 182. Bayes Theorem P(S B) = P(B S) P(B S) P(S) P(S)+P(B H)P(H) S: Spam H: Ham (not spam) B: ‘Buy’ P(spam if “Buy”) = 20 25 25 100 20 25 25 100
  183. 183. Bayes Theorem P(S B) = P(B S) P(B S) P(S) P(S)+P(B H)P(H) S: Spam H: Ham (not spam) B: ‘Buy’ P(spam if “Buy”) = 20 25 25 100 20 25 25 100 +
  184. 184. Bayes Theorem P(S B) = P(B S) P(B S) P(S) P(S)+P(B H)P(H) S: Spam H: Ham (not spam) B: ‘Buy’ P(spam if “Buy”) = 20 25 25 100 20 25 25 100 5 75+
  185. 185. Bayes Theorem P(S B) = P(B S) P(B S) P(S) P(S)+P(B H)P(H) S: Spam H: Ham (not spam) B: ‘Buy’ P(spam if “Buy”) = 20 25 25 100 20 25 25 100 5 75 75 100+
  186. 186. Bayes Theorem P(S B) = P(B S) P(B S) P(S) P(S)+P(B H)P(H) S: Spam H: Ham (not spam) B: ‘Buy’ P(spam if “Buy”) = 20 25 25 100 20 25 25 100 5 75 75 100+ = 80%
  187. 187. Naive Bayes
  188. 188. P(“Buy” & “Cheap”) = P(“Buy”) P(“Cheap”) Naive Bayes
  189. 189. P(“Buy” & “Cheap”) = P(“Buy”) P(“Cheap”) P(B C) = P(B) P(C) U Naive Bayes
  190. 190. P(“Buy” & “Cheap”) = P(“Buy”) P(“Cheap”) Naive P(B C) = P(B) P(C) U Naive Bayes
  191. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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
  205. 205. Thank you!
  206. 206. Thank you! Subscribe, like, share, comment youtube.com/c/LuisSerrano
  207. 207. Thank you! @luis_likes_math Subscribe, like, share, comment youtube.com/c/LuisSerrano

×