Professional Documents
Culture Documents
Materi 06 - Naive Bayes 2021
Materi 06 - Naive Bayes 2021
Tim Pengajaran
Mata Kuliah Machine Learning
Jurusan Teknologi Informasi Tahun 2021
Disclaimer
▪ This presentation material, including examples, images, references
are provided for informational and explanation assistance only
• Bayes’ Theorem
• Generative and Discriminative Models
• Naive Bayes Computation
𝑃 𝑥1 , … , 𝑥𝑛 𝑦 𝑃 𝑦
𝑃 𝑦 𝑥1 , … , 𝑥𝑛 =
𝑃 𝑥1 , … , 𝑥𝑛
• 𝑦 is the positive class, 𝑥1 is the first feature for the instance, and 𝑛 is the number of features.
• 𝑃 𝑥1 , … , 𝑥𝑛 is constant for all inputs, so we can omit it; the probability of observing a
particular feature in the training set does not vary for different test instances.
• This leaves two terms: the prior class probability, 𝑃 𝑦 , and the conditional probability,
𝑃 𝑥1 , … , 𝑥𝑛 𝑦 . Naive Bayes estimates these terms using maximum a posteriori estimation
(MAP).
• 𝑃 𝑦 is simply the frequency of each class in the training set.
𝑃 𝑥1 , … , 𝑥𝑛 𝑦 𝑃 𝑦
𝑃 𝑦 𝑥1 , … , 𝑥𝑛 =
𝑃 𝑥1 , … , 𝑥𝑛
𝑃 𝑦 𝑥1 , … , 𝑥𝑛 ∝ 𝑃 𝑦 𝑃 𝑥1 𝑦 𝑃 𝑥2 𝑦 … . 𝑃 𝑥𝑛 𝑦
𝑛
𝑃 𝑦 𝑥1 , … , 𝑥𝑛 ∝ 𝑃 𝑦 ෑ 𝑃 𝑥𝑖 𝑦
𝑖=1
• Bernoulli Naive Bayes – Similar to the multinomial one but the predictors
are Boolean variables. The parameters that is used to predict the class
variable take up only values yes or no, for example if a word occurs in the
text or not.
P(AB)
P ( B| A ) =
P(A)
homework
• Classify whether the day is suitable for playing golf, given
the features of the day.