Bayes Rule and Bayes Classifiers - PowerPoint PPT Presentation

1 / 57
About This Presentation
Title:

Bayes Rule and Bayes Classifiers

Description:

Bayes Rule and Bayes Classifiers Andrew W. Moore awm_at_cs.cmu.edu 412-268-7599 http://www.cs.cmu.edu/~awm/tutorials – PowerPoint PPT presentation

Number of Views:137
Avg rating:3.0/5.0
Slides: 58
Provided by: awm4
Category:

less

Transcript and Presenter's Notes

Title: Bayes Rule and Bayes Classifiers


1
Bayes Rule and Bayes Classifiers
Andrew W. Moore
awm_at_cs.cmu.edu 412-268-7599 http//www.cs.cmu.edu/
awm/tutorials
2
Outline
  • Reasoning with uncertainty
  • Also known as probability
  • This is a fundamental building block
  • Its really going to be worth it

3
Discrete Random Variables
  • A is a Boolean-valued random variable if A
    denotes an event, and there is some degree of
    uncertainty as to whether A occurs.
  • Examples
  • A The next patient you examine is suffering
    from inhalational anthrax
  • A The next patient you examine has a cough
  • A There is an active terrorist cell in your city

4
Probabilities
  • We write P(A) as the fraction of possible worlds
    in which A is true
  • We could at this point spend 2 hours on the
    philosophy of this.
  • But we wont.

5
Visualizing A


Event space of all possible worlds
P(A) Area of reddish oval
Worlds in which A is true
Its area is 1
Worlds in which A is False
6
The Axioms Of Probability
7
The Axioms Of Probability
  • 0 lt P(A) lt 1
  • P(True) 1
  • P(False) 0
  • P(A or B) P(A) P(B) - P(A and B)

The area of A cant get any smaller than 0
And a zero area would mean no world could ever
have A true
8
Interpreting the axioms
  • 0 lt P(A) lt 1
  • P(True) 1
  • P(False) 0
  • P(A or B) P(A) P(B) - P(A and B)

The area of A cant get any bigger than 1
And an area of 1 would mean all worlds will have
A true
9
Interpreting the axioms
  • 0 lt P(A) lt 1
  • P(True) 1
  • P(False) 0
  • P(A or B) P(A) P(B) - P(A and B)

10
Interpreting the axioms
  • 0 lt P(A) lt 1
  • P(True) 1
  • P(False) 0
  • P(A or B) P(A) P(B) - P(A and B)

A
P(A or B)
B
B
P(A and B)
Simple addition and subtraction
11
These Axioms are Not to be Trifled With
  • There have been attempts to do different
    methodologies for uncertainty
  • Fuzzy Logic
  • Three-valued logic
  • Dempster-Shafer
  • Non-monotonic reasoning
  • But the axioms of probability are the only system
    with this property
  • If you gamble using them you cant be
    unfairly exploited by an opponent using some
    other system di Finetti 1931

12
Another important theorem
  • 0 lt P(A) lt 1, P(True) 1, P(False) 0
  • P(A or B) P(A) P(B) - P(A and B)
  • From these we can prove
  • P(A) P(A and B) P(A and not B)

A
B
13
Conditional Probability
  • P(AB) Fraction of worlds in which B is true
    that also have A true

H Have a headache F Coming down with
Flu P(H) 1/10 P(F) 1/40 P(HF)
1/2 Headaches are rare and flu is rarer, but if
youre coming down with flu theres a 50-50
chance youll have a headache.
F
H
14
Conditional Probability
P(HF) Fraction of flu-inflicted worlds in
which you have a headache worlds with flu and
headache ------------------------------------
worlds with flu Area of H and F
region ------------------------------
Area of F region P(H and F)
--------------- P(F)
H Have a headache F Coming down with
Flu P(H) 1/10 P(F) 1/40 P(HF) 1/2
15
Definition of Conditional Probability
P(A and B) P(AB)
----------- P(B)
Corollary The Chain Rule
P(A and B) P(AB) P(B)
16
Probabilistic Inference
H Have a headache F Coming down with
Flu P(H) 1/10 P(F) 1/40 P(HF) 1/2
One day you wake up with a headache. You think
Drat! 50 of flus are associated with headaches
so I must have a 50-50 chance of coming down with
flu Is this reasoning good?
17
Probabilistic Inference
H Have a headache F Coming down with
Flu P(H) 1/10 P(F) 1/40 P(HF) 1/2
P(F and H) P(FH)
18
Probabilistic Inference
H Have a headache F Coming down with
Flu P(H) 1/10 P(F) 1/40 P(HF) 1/2
19
What we just did
  • P(A B) P(AB) P(B)
  • P(BA) ----------- ---------------
  • P(A) P(A)
  • This is Bayes Rule

Bayes, Thomas (1763) An essay towards solving a
problem in the doctrine of chances. Philosophical
Transactions of the Royal Society of London,
53370-418
20
Bad Hygiene
Good Hygiene
  • You are a health official, deciding whether to
    investigate a restaurant
  • You lose a dollar if you get it wrong.
  • You win a dollar if you get it right
  • Half of all restaurants have bad hygiene
  • In a bad restaurant, ¾ of the menus are smudged
  • In a good restaurant, 1/3 of the menus are
    smudged
  • You are allowed to see a randomly chosen menu
  • Whats the probability that the restaurant is bad
    if the menu is smudged?

21
(No Transcript)
22
(No Transcript)
23
Bayesian Diagnosis
Buzzword Meaning In our example Our examples value
True State The true state of the world, which you would like to know Is the restaurant bad?
24
Bayesian Diagnosis
Buzzword Meaning In our example Our examples value
True State The true state of the world, which you would like to know Is the restaurant bad?
Prior Prob(true state x) P(Bad) 1/2
25
Bayesian Diagnosis
Buzzword Meaning In our example Our examples value
True State The true state of the world, which you would like to know Is the restaurant bad?
Prior Prob(true state x) P(Bad) 1/2
Evidence Some symptom, or other thing you can observe Smudge
26
Bayesian Diagnosis
Buzzword Meaning In our example Our examples value
True State The true state of the world, which you would like to know Is the restaurant bad?
Prior Prob(true state x) P(Bad) 1/2
Evidence Some symptom, or other thing you can observe
Conditional Probability of seeing evidence if you did know the true state P(SmudgeBad) 3/4
Conditional Probability of seeing evidence if you did know the true state P(Smudgenot Bad) 1/3
27
Bayesian Diagnosis
Buzzword Meaning In our example Our examples value
True State The true state of the world, which you would like to know Is the restaurant bad?
Prior Prob(true state x) P(Bad) 1/2
Evidence Some symptom, or other thing you can observe
Conditional Probability of seeing evidence if you did know the true state P(SmudgeBad) 3/4
Conditional Probability of seeing evidence if you did know the true state P(Smudgenot Bad) 1/3
Posterior The Prob(true state x some evidence) P(BadSmudge) 9/13
28
Bayesian Diagnosis
Buzzword Meaning In our example Our examples value
True State The true state of the world, which you would like to know Is the restaurant bad?
Prior Prob(true state x) P(Bad) 1/2
Evidence Some symptom, or other thing you can observe
Conditional Probability of seeing evidence if you did know the true state P(SmudgeBad) 3/4
Conditional Probability of seeing evidence if you did know the true state P(Smudgenot Bad) 1/3
Posterior The Prob(true state x some evidence) P(BadSmudge) 9/13
Inference, Diagnosis, Bayesian Reasoning Getting the posterior from the prior and the evidence
29
Bayesian Diagnosis
Buzzword Meaning In our example Our examples value
True State The true state of the world, which you would like to know Is the restaurant bad?
Prior Prob(true state x) P(Bad) 1/2
Evidence Some symptom, or other thing you can observe
Conditional Probability of seeing evidence if you did know the true state P(SmudgeBad) 3/4
Conditional Probability of seeing evidence if you did know the true state P(Smudgenot Bad) 1/3
Posterior The Prob(true state x some evidence) P(BadSmudge) 9/13
Inference, Diagnosis, Bayesian Reasoning Getting the posterior from the prior and the evidence
Decision theory Combining the posterior with known costs in order to decide what to do
30
Many Pieces of Evidence
31
Many Pieces of Evidence
Pat walks in to the surgery. Pat is sore and has
a headache but no cough
32
Many Pieces of Evidence
Priors
P(Flu) 1/40 P(Not Flu) 39/40

P( Headache Flu ) 1/2 P( Headache not Flu ) 7 / 78
P( Cough Flu ) 2/3 P( Cough not Flu ) 1/6
P( Sore Flu ) 3/4 P( Sore not Flu ) 1/3
Pat walks in to the surgery. Pat is sore and has
a headache but no cough
Conditionals
33
Many Pieces of Evidence
Priors
P(Flu) 1/40 P(Not Flu) 39/40

P( Headache Flu ) 1/2 P( Headache not Flu ) 7 / 78
P( Cough Flu ) 2/3 P( Cough not Flu ) 1/6
P( Sore Flu ) 3/4 P( Sore not Flu ) 1/3
Pat walks in to the surgery. Pat is sore and has
a headache but no cough What is P( F H and not
C and S ) ?
Conditionals
34
P(Flu) 1/40 P(Not Flu) 39/40

P( Headache Flu ) 1/2 P( Headache not Flu ) 7 / 78
P( Cough Flu ) 2/3 P( Cough not Flu ) 1/6
P( Sore Flu ) 3/4 P( Sore not Flu ) 1/3
The Naïve Assumption
35
P(Flu) 1/40 P(Not Flu) 39/40

P( Headache Flu ) 1/2 P( Headache not Flu ) 7 / 78
P( Cough Flu ) 2/3 P( Cough not Flu ) 1/6
P( Sore Flu ) 3/4 P( Sore not Flu ) 1/3
The Naïve Assumption
If I know Pat has Flu and I want to know if Pat
has a cough it wont help me to find out
whether Pat is sore
36
P(Flu) 1/40 P(Not Flu) 39/40

P( Headache Flu ) 1/2 P( Headache not Flu ) 7 / 78
P( Cough Flu ) 2/3 P( Cough not Flu ) 1/6
P( Sore Flu ) 3/4 P( Sore not Flu ) 1/3
The Naïve Assumption
If I know Pat has Flu and I want to know if Pat
has a cough it wont help me to find out
whether Pat is sore
Coughing is explained away by Flu
37
P(Flu) 1/40 P(Not Flu) 39/40

P( Headache Flu ) 1/2 P( Headache not Flu ) 7 / 78
P( Cough Flu ) 2/3 P( Cough not Flu ) 1/6
P( Sore Flu ) 3/4 P( Sore not Flu ) 1/3
The Naïve Assumption General Case
If I know the true state and I want to know
about one of the symptoms then it wont help me
to find out anything about the other symptoms
Other symptoms are explained away by the true
state
38
P(Flu) 1/40 P(Not Flu) 39/40

P( Headache Flu ) 1/2 P( Headache not Flu ) 7 / 78
P( Cough Flu ) 2/3 P( Cough not Flu ) 1/6
P( Sore Flu ) 3/4 P( Sore not Flu ) 1/3
The Naïve Assumption General Case
If I know the true state and I want to know
about one of the symptoms then it wont help me
to find out anything about the other symptoms
  • What are the good things about the Naïve
    assumption?
  • What are the bad things?

Other symptoms are explained away by the true
state
39
P(Flu) 1/40 P(Not Flu) 39/40

P( Headache Flu ) 1/2 P( Headache not Flu ) 7 / 78
P( Cough Flu ) 2/3 P( Cough not Flu ) 1/6
P( Sore Flu ) 3/4 P( Sore not Flu ) 1/3
40
P(Flu) 1/40 P(Not Flu) 39/40

P( Headache Flu ) 1/2 P( Headache not Flu ) 7 / 78
P( Cough Flu ) 2/3 P( Cough not Flu ) 1/6
P( Sore Flu ) 3/4 P( Sore not Flu ) 1/3
41
P(Flu) 1/40 P(Not Flu) 39/40

P( Headache Flu ) 1/2 P( Headache not Flu ) 7 / 78
P( Cough Flu ) 2/3 P( Cough not Flu ) 1/6
P( Sore Flu ) 3/4 P( Sore not Flu ) 1/3
42
P(Flu) 1/40 P(Not Flu) 39/40

P( Headache Flu ) 1/2 P( Headache not Flu ) 7 / 78
P( Cough Flu ) 2/3 P( Cough not Flu ) 1/6
P( Sore Flu ) 3/4 P( Sore not Flu ) 1/3
How do I get P(H and not C and S and F)?
43
P(Flu) 1/40 P(Not Flu) 39/40

P( Headache Flu ) 1/2 P( Headache not Flu ) 7 / 78
P( Cough Flu ) 2/3 P( Cough not Flu ) 1/6
P( Sore Flu ) 3/4 P( Sore not Flu ) 1/3
44
P(Flu) 1/40 P(Not Flu) 39/40

P( Headache Flu ) 1/2 P( Headache not Flu ) 7 / 78
P( Cough Flu ) 2/3 P( Cough not Flu ) 1/6
P( Sore Flu ) 3/4 P( Sore not Flu ) 1/3
Chain rule P( and ) P( ) P( )
45
P(Flu) 1/40 P(Not Flu) 39/40

P( Headache Flu ) 1/2 P( Headache not Flu ) 7 / 78
P( Cough Flu ) 2/3 P( Cough not Flu ) 1/6
P( Sore Flu ) 3/4 P( Sore not Flu ) 1/3
Naïve assumption lack of cough and soreness have
no effect on headache if I am already assuming Flu
46
P(Flu) 1/40 P(Not Flu) 39/40

P( Headache Flu ) 1/2 P( Headache not Flu ) 7 / 78
P( Cough Flu ) 2/3 P( Cough not Flu ) 1/6
P( Sore Flu ) 3/4 P( Sore not Flu ) 1/3
Chain rule P( and ) P( ) P( )
47
P(Flu) 1/40 P(Not Flu) 39/40

P( Headache Flu ) 1/2 P( Headache not Flu ) 7 / 78
P( Cough Flu ) 2/3 P( Cough not Flu ) 1/6
P( Sore Flu ) 3/4 P( Sore not Flu ) 1/3
Naïve assumption Sore has no effect on Cough if
I am already assuming Flu
48
P(Flu) 1/40 P(Not Flu) 39/40

P( Headache Flu ) 1/2 P( Headache not Flu ) 7 / 78
P( Cough Flu ) 2/3 P( Cough not Flu ) 1/6
P( Sore Flu ) 3/4 P( Sore not Flu ) 1/3
Chain rule P( and ) P( ) P( )
49
P(Flu) 1/40 P(Not Flu) 39/40

P( Headache Flu ) 1/2 P( Headache not Flu ) 7 / 78
P( Cough Flu ) 2/3 P( Cough not Flu ) 1/6
P( Sore Flu ) 3/4 P( Sore not Flu ) 1/3
50
P(Flu) 1/40 P(Not Flu) 39/40

P( Headache Flu ) 1/2 P( Headache not Flu ) 7 / 78
P( Cough Flu ) 2/3 P( Cough not Flu ) 1/6
P( Sore Flu ) 3/4 P( Sore not Flu ) 1/3
51
P(Flu) 1/40 P(Not Flu) 39/40

P( Headache Flu ) 1/2 P( Headache not Flu ) 7 / 78
P( Cough Flu ) 2/3 P( Cough not Flu ) 1/6
P( Sore Flu ) 3/4 P( Sore not Flu ) 1/3
52
P(Flu) 1/40 P(Not Flu) 39/40

P( Headache Flu ) 1/2 P( Headache not Flu ) 7 / 78
P( Cough Flu ) 2/3 P( Cough not Flu ) 1/6
P( Sore Flu ) 3/4 P( Sore not Flu ) 1/3
0.1139 (11 chance of Flu, given symptoms)
53
Building A Bayes Classifier
Priors
P(Flu) 1/40 P(Not Flu) 39/40

P( Headache Flu ) 1/2 P( Headache not Flu ) 7 / 78
P( Cough Flu ) 2/3 P( Cough not Flu ) 1/6
P( Sore Flu ) 3/4 P( Sore not Flu ) 1/3
Conditionals
54
The General Case
55
Building a naïve Bayesian Classifier
  • Assume
  • True state has N possible values 1, 2, 3 .. N
  • There are K symptoms called Symptom1, Symptom2,
    SymptomK
  • Symptomi has Mi possible values 1, 2, .. Mi

P(State1) ___ P(State2) ___ P(StateN) ___

P( Sym11 State1 ) ___ P( Sym11 State2 ) ___ P( Sym11 StateN ) ___
P( Sym12 State1 ) ___ P( Sym12 State2 ) ___ P( Sym12 StateN ) ___

P( Sym1M1 State1 ) ___ P( Sym1M1 State2 ) ___ P( Sym1M1 StateN ) ___

P( Sym21 State1 ) ___ P( Sym21 State2 ) ___ P( Sym21 StateN ) ___
P( Sym22 State1 ) ___ P( Sym22 State2 ) ___ P( Sym22 StateN ) ___

P( Sym2M2 State1 ) ___ P( Sym2M2 State2 ) ___ P( Sym2M2 StateN ) ___

P( SymK1 State1 ) ___ P( SymK1 State2 ) ___ P( SymK1 StateN ) ___
P( SymK2 State1 ) ___ P( SymK2 State2 ) ___ P( SymK2 StateN ) ___

P( SymKMK State1 ) ___ P( SymKM1 State2 ) ___ P( SymKM1 StateN ) ___
56
Building a naïve Bayesian Classifier
  • Assume
  • True state has N values 1, 2, 3 .. N
  • There are K symptoms called Symptom1, Symptom2,
    SymptomK
  • Symptomi has Mi values 1, 2, .. Mi

P(State1) ___ P(State2) ___ P(StateN) ___

P( Sym11 State1 ) ___ P( Sym11 State2 ) ___ P( Sym11 StateN ) ___
P( Sym12 State1 ) ___ P( Sym12 State2 ) ___ P( Sym12 StateN ) ___

P( Sym1M1 State1 ) ___ P( Sym1M1 State2 ) ___ P( Sym1M1 StateN ) ___

P( Sym21 State1 ) ___ P( Sym21 State2 ) ___ P( Sym21 StateN ) ___
P( Sym22 State1 ) ___ P( Sym22 State2 ) ___ P( Sym22 StateN ) ___

P( Sym2M2 State1 ) ___ P( Sym2M2 State2 ) ___ P( Sym2M2 StateN ) ___

P( SymK1 State1 ) ___ P( SymK1 State2 ) ___ P( SymK1 StateN ) ___
P( SymK2 State1 ) ___ P( SymK2 State2 ) ___ P( SymK2 StateN ) ___

P( SymKMK State1 ) ___ P( SymKM1 State2 ) ___ P( SymKM1 StateN ) ___
Example P( Anemic Liver Cancer) 0.21
57
P(State1) ___ P(State2) ___ P(StateN) ___

P( Sym11 State1 ) ___ P( Sym11 State2 ) ___ P( Sym11 StateN ) ___
P( Sym12 State1 ) ___ P( Sym12 State2 ) ___ P( Sym12 StateN ) ___

P( Sym1M1 State1 ) ___ P( Sym1M1 State2 ) ___ P( Sym1M1 StateN ) ___

P( Sym21 State1 ) ___ P( Sym21 State2 ) ___ P( Sym21 StateN ) ___
P( Sym22 State1 ) ___ P( Sym22 State2 ) ___ P( Sym22 StateN ) ___

P( Sym2M2 State1 ) ___ P( Sym2M2 State2 ) ___ P( Sym2M2 StateN ) ___

P( SymK1 State1 ) ___ P( SymK1 State2 ) ___ P( SymK1 StateN ) ___
P( SymK2 State1 ) ___ P( SymK2 State2 ) ___ P( SymK2 StateN ) ___

P( SymKMK State1 ) ___ P( SymKM1 State2 ) ___ P( SymKM1 StateN ) ___
58
P(State1) ___ P(State2) ___ P(StateN) ___

P( Sym11 State1 ) ___ P( Sym11 State2 ) ___ P( Sym11 StateN ) ___
P( Sym12 State1 ) ___ P( Sym12 State2 ) ___ P( Sym12 StateN ) ___

P( Sym1M1 State1 ) ___ P( Sym1M1 State2 ) ___ P( Sym1M1 StateN ) ___

P( Sym21 State1 ) ___ P( Sym21 State2 ) ___ P( Sym21 StateN ) ___
P( Sym22 State1 ) ___ P( Sym22 State2 ) ___ P( Sym22 StateN ) ___

P( Sym2M2 State1 ) ___ P( Sym2M2 State2 ) ___ P( Sym2M2 StateN ) ___

P( SymK1 State1 ) ___ P( SymK1 State2 ) ___ P( SymK1 StateN ) ___
P( SymK2 State1 ) ___ P( SymK2 State2 ) ___ P( SymK2 StateN ) ___

P( SymKMK State1 ) ___ P( SymKM1 State2 ) ___ P( SymKM1 StateN ) ___
59
Conclusion
  • Bayesian and conditional probabilityare two
    important concepts
  • Its simple dont let wooly academic types trick
    you into thinking it is fancy.
  • You should know
  • What are Bayesian Reasoning, Conditional
    Probabilities, Priors, Posteriors.
  • Appreciate how conditional probabilities are
    manipulated.
  • Why the Naïve Bayes Assumption is Good.
  • Why the Naïve Bayes Assumption is Evil.
Write a Comment
User Comments (0)
About PowerShow.com