3 - (9-5) Naïve Bayesian Classifiers
3 - (9-5) Naïve Bayesian Classifiers
• Because the first flip comes up tails, there are only four possible outcomes: TTT,
TTH, THT, and THH, i.e., |F| = 4
• This suggests that we should assign the probability of |E|/|F| = 2/4 = 1/2 to E,
given that F occurs.
Definition 3:
• Let E and F be events with p(F) > 0.
• The conditional probability of E given F, denoted by p(E ∣ F) is:
• p(E ∣ F) = p(E ∩ F)/p(F)
p(x |C i )P (C i )
P (C i | x ) =
p(x )
p(x |C i )P (C i )
= K
∑ p(x|C k )P(C k )
k =1
Naïve Bayesian Classifiers David O. Johnson EECS 658 (Fall 2024) 22
Naïve Bayesian Classifier
• In plain English, using Bayesian probability terminology, this
equation can be written as:
posterior = prior · likelihood / evidence
• In practice, there is interest only in the numerator of that
fraction, because the denominator does not depend on any
Ci and the values of the features x are given, so that the
denominator is effectively constant.
• This reduces the problem to:
– Calculating the posterior numerator of the sample for each
class:
posterior numerator = prior · likelihood
– Classifying the sample based on the largest posterior numerator
p(xk|Ci) =
• where:
x = the value of feature k for the sample we are classifying
μk = mean value of feature k for the entire training set
σk2 = variance of feature k for the entire training set
e = 2.71828…
Training Set
Gorilla height (feet) weight (lbs) footsize(inches)
male 6 180 12 Test Set (1 gorilla):
male 5.92 (5'11") 190 11 •height = 6 feet
male 5.58 (5'7") 170 12 •weight = 130 lbs
male 5.92 (5'11") 165 10 •footsize = 8 inches
female 5 100 6 •The test set could be larger.
female 5.5 (5'6") 150 8 •Each sample would be classified
female 5.42 (5'5") 130 7 in the same manner.
female 5.75 (5'9") 150 9
•Now we can calculate the numerator of the posterior probability that the gorilla is a
male.
•posterior numerator (male) = P(male)·p(height|male)·p(weight|male)·p(footsize|male)
•posterior numerator (male) = 0.5·1.5789·(5.9881·10-6 )·(1.3112·10-3)
•posterior numerator (male) = 6.1984·10-9