CPE412 Pattern Recognition (Week 4)
CPE412 Pattern Recognition (Week 4)
2
Week 3
3
Week 3
4
Week 3
5
Week 3
6
Week 3
7
Week 3
8
P(B A)P( A)
P( A B ) =
P(B)
P ( B A) P ( A)
P ( A B) =
å P(B A )P( A )
n n n
9
10
11
using feature x
make it more
accurate
12
13
14
15
Loss for taking
specific wrong
action (it's given
to you)
16
17
18
19
Let's think of a market. Two different brands of
eggs come to the market. Information about
eggs from the experience gained and the records
kept is as follows:
◦ Brands: Br1 Egg and Br2 Egg
◦ Daily supply amount: Br1 800, Br2 600
◦ Broken egg(K) rate: 05%
The question here is: what is the probability that
an egg coming from Br2 will be broken in one
day?
20
A total of 1400 eggs,
600 of them come from Br2
70 broken eggs per day (total * broken rate)
If we assume equal distribution of the broken
parts according to the brands, there are 35
Br2
Then the probability of Br2 being broken is
35/600 = 0.058333
21
P(Br2|K) * P (K)
P(K|Br2)=
P(Br2)
22
P(Br2|K) * P (K)
P(K|Br2)=
P(Br2)
23
Members of a consulting company rent a car at a rate of 60%
from the 1st enterprise, 30% from the 2nd enterprise and 10%
from the 3rd enterprise. If 9% of the vehicles coming from the
first enterprise, 20% of the vehicles coming from the second
enterprise and 6% of the vehicles coming from the third
enterprise require maintenance;
◦ a) What is the probability that a vehicle rented to the company will require
maintenance?
◦ b) What is the probability that the vehicle requiring maintenance came
from the second enterprise?
B: A car requires maintenance.
Ai: Let the car come from the 1st, 2nd or 3rd enterprise With i=
1, 2, 3.
24
P(B)—> the probability that the car will require
maintenance.
From the total probability is found using:
Then 12% of the vehicles rented by this company will require maintenance.
25
the probability that the vehicle requiring
maintenance came from the second enterprise:
26
The Classification Problem Katydids
(informal definition)
Katydid or Grasshopper?
For any domain of interest, we can measure features
Abdomen Thorax
Length Length Antennae
Length
Mandible
Size
Spiracle
Diameter Leg Length
Grasshoppers Katydids
10
9
8
7
Antenna Length
6
5
4
3
2
1
1 2 3 4 5 6 7 8 9 10
Abdomen Length
Antenna Length
6
5
4
3
2
1
1 2 3 4 5 6 7 8 9 10
Katydids
Grasshoppers
We can leave the
histograms as they are,
or we can summarize
them with two normal
distributions.
• We can just ask ourselves, give the distributions of antennae lengths we have
seen, is it more probable that our insect is a Grasshopper or a Katydid.
• There is a formal way to discuss the most probable classification…
Antennae length is 3
p(cj | d) = probability of class cj, given that we have observed
d
P(Grasshopper | 3 ) = 10 / (10 + 2) = 0.833
P(Katydid | 3 ) = 2 / (10 + 2) = 0.166
10
Antennae length is 3
p(cj | d) = probability of class cj, given that we have observed
d
P(Grasshopper | 7 ) = 3 / (3 + 9) = 0.250
P(Katydid | 7 ) = 9 / (3 + 9) = 0.750
9
3
Antennae length is 7
p(cj | d) = probability of class cj, given that we have observed
d
P(Grasshopper | 5 ) = 6 / (6 + 6) = 0.500
P(Katydid | 5 ) = 6 / (6 + 6) = 0.500
66
Antennae length is
5
That was a visual intuition for a simple case of the Bayes
classifier, also called:
• Idiot Bayes
• Naïve Bayes
• Simple Bayes
Officer Drew
The probability of
class cj generating
instance d, equals….
The probability of class cj
generating the observed
value for feature 1,
multiplied by..
The probability of class cj
generating the observed
value for feature 2,
multiplied by..
To simplify the task, naïve Bayesian classifiers
assume attributes have independent
distributions, and thereby estimate
p(d|cj) = p(d1|cj) * p(d2|cj) * ….*
p(dn|cj)
Officer
Drew is
blue-eyed,
over 170cm
tall, and has p(officer drew| Female) = 2/5 * 3/5 * ….
long hair
p(officer drew| Male) = 2/3 * 2/3 * ….
The Naive Bayes classifiers is
often represented as this type of cj
graph…
p(d1|cj) p(d2|cj)
… p(dn|cj)