artificial intelligence cs 165a thursday, november 29, 2007 probabilistic reasoning / bayesian...

Post on 31-Dec-2015

213 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Artificial Intelligence

CS 165A

Thursday, November 29, 2007

Probabilistic Reasoning / Bayesian networks (Ch 14)

2

Notes

• Note the reading assignments for next week

3

Belief nets

• General assumptions– A DAG is a reasonable representation of the influences among the

variables Leaves of the DAG have no direct influence on other variables

– Conditional independences cause the graph to be much less than fully connected (the system is locally structured, or sparse)

– The CPTs are relatively easy to state Many can be estimated as a canonical distribution (a standard

pattern – just specify the parameters) or as a deterministic node (direct function – logical or numerical combination – of parents)

4

What are belief nets for?

• Given the structure, we can now pose queries:– Typically: P(Query | Evidence) or P(Cause | Symptoms)

– P(X1 | X4, X5)

– P(Earthquake | JohnCalls)

– P(Burglary | JohnCalls, MaryCalls)

Query variable Evidence variables

• This is very similar to:– TELL(KB, JohnCalls, MaryCalls)– ASK(KB, Burglary)

• Or agent view: P(state of world | percepts) leads to choice of action

5

X

Y

P(X)

P(Y|X)

ASK P(X|Y)

Raining

Wet grass

X

Y

P(X)

P(Y|X)

Z P(Z|Y)

ASK P(X|Z)

Rained

Wet grass

Wormsighting

6

Thursday Quiz

1. What is the joint probability distribution of the random variables described by this belief net?– I.e., what is P(U, V, W, X, Y, Z)?

2. Variables W and X area) Independentb) Independent given Uc) Independent given Y(choose one)

3. If you know the CPTs, is it possible to compute P(Z | U)?

U

X

V

W

ZY

7

Review

U

X

V

W

ZY

P(V)

P(X|U,V)

P(U)

P(W|U)

P(Z|X)P(Y|W,X)

Given this Bayesian network:

1. What are the CPTs?

2. What is the joint probability distribution of all the variables?

3. How would we calculate P(X | W, Y, Z)?

P(U,V,W,X,Y,Z) = product of the CPTs

= P(U) P(V) P(W|U) P(X|U,V) P(Y|W,X) P(Z|X)

8

How to construct a belief net

• Choose the random variables that describe the domain– These will be the nodes of the graph

• Choose a left-to-right ordering of the variables that indicates a general order of influence– “Root causes” to the left, symptoms to the right

X1 X2 X3 X4 X5

Causes Symptoms

9

How to construct a belief net (cont.)

• Draw arcs from left to right to indicate “direct influence” (causality) among variables– May have to reorder some nodes

X1 X2 X3 X4 X5

• Define the conditional probability table (CPT) for each node– P(node | parents)

P(X1)

P(X2)

P(X3 | X1,X2)

P(X4 | X2,X3)

P(X5 | X4)

10

How to construct a belief net (cont.)

• To calculate any probability from the full joint distribution, use (1) definition of conditional probability and (2) marginalization– P(red vars | green vars) = ? (ignoring the blue vars)

})({

}){},{},({

})({}){},({

}){|}({gP

bgrP

gPgrP

grP B

R

grP

grP

}){},({

}){},({

))(|(}){},{},({where ii nparentsnPbgrP

Joint PD

Marginalization

11

Example: Flu and measles

Flu

MeaslesFever

SpotsP(Flu)

P(Measles)

P(Spots | Measles)

P(Fever | Flu, Measles)

To create the belief net:• Choose variables (evidence and query)• Choose an ordering and create links (direct influences)• Fill in probabilities (CPTs)

12

Example: Flu and measles

Flu

MeaslesFever

Spots

P(Flu) = 0.01P(Measles) = 0.001

P(Flu)

P(Measles)

P(Spots | Measles)

P(Fever | Flu, Measles)

P(Spots | Measles) = [0, 0.9]P(Fever | Flu, Measles) = [0.01, 0.8, 0.9, 1.0]

Compute P(Flu | Fever) and P(Flu | Fever, Spots).Are they equivalent?

CPTs:

13

Conditional Independence

• Can we determine conditional independence of variables directly from the graph?

• A set of nodes X is independent of another set of nodes Y, given a set of (evidence) nodes E, if every path from X to Y is d-separated, or blocked, by E

3 ways to block paths from X to Y, given E

The set of nodes E d-separates sets X and Y

14

Examples

X Z Y X ind. of Y? X ind. of Y given Z?

X

Z

Y X ind. of Y? X ind. of Y given Z?

X Z Y X ind. of Y? X ind. of Y given Z?

X Z Y X ind. of Y? X ind. of Y given Z?

X Z Y X ind. of Y? X ind. of Y given Z?

15

Independence (again)

• Variables X and Y are independent if and only if– P(X, Y) = P(X) P(Y)

– P(X | Y) = P(X)

– P(Y | X) = P(Y)

• We can determine independence of variables in a belief net directly from the graph– Variables X and Y are independent if they share no common

ancestry I.e., the set of { X, parents of X, grandparents of X, … } has a

null intersection with the set of {Y, parents of Y, grandparents of Y, … }

X Y

X, Y dependent

16

Conditional Independence

• X and Y are (conditionally) independent given E iff– P(X | Y, E) = P(X | E)

– P(Y | X, E) = P(Y | E)

• {X1,…,Xn} and {Y1,…,Ym} are conditionally independent given {E1,…,Ek} iff

– P(X1,…,Xn | Y1, …, Ym, E1, …,Ek) = P(X1,…,Xn | E1, …,Ek)

– P(Y1, …, Ym | X1,…,Xn, E1, …,Ek) = P(Y1, …, Ym | E1, …,Ek)

• We can determine conditional independence of variables (and sets of variables) in a belief net directly from the graph

17

How to determine conditional independence

• A set of nodes X is independent of another set of nodes Y, given a set of (evidence) nodes E, if every path from Xi to Yj is d-separated, or blocked– The set of nodes E d-separates sets X and Y

• The textbook (p. 499) mentions the Markov blanket, which is the same general concept– But the description is brief and unclear…!

• There are three ways to block a path from Xi to Yj

18

X Z Y

#1

X Z Y

X Z Y

#2

X Z Y

#3

This variable is not in E!

(Nor are its descendents)

The variable Z is in E

The variable Z is in E

19

Examples

G WR

Rain WetGrass

Worms

P(W | R, G) = P(W | G)

F CT

Tired Flu Cough

P(T | C, F) = P(T | F)

M IW

Work Money Inherit

P(W | I, M) P(W | M)

P(W | I) = P(W)

20

Examples

X Z Y X ind. of Y? X ind. of Y given Z?

X Z Y X ind. of Y? X ind. of Y given Z?

X Z Y X ind. of Y? X ind. of Y given Z?

X Z Y X ind. of Y? X ind. of Y given Z?

Yes Yes

X

Z

Y X ind. of Y? X ind. of Y given Z?

No Yes

No Yes

Yes No

No No

21

Examples (cont.)

X

Z

Y

X – wet grass

Y – rainbow

Z – rain

X – rain

Y – sprinkler

Z – wet grass

W – worms

P(X, Y) P(X) P(Y)

P(X | Y, Z) = P(X | Z)

P(X, Y) = P(X) P(Y)

P(X | Y, Z) P(X | Z)

P(X | Y, W) P(X | W)

X

Z

Y

W

Are X and Y ind.? Are X and Y cond. ind. given…?

22

Examples

X

W

Y

X – rainY – sprinklerZ – rainbowW – wet grass

Z

X

W

Y

X – rainY – sprinklerZ – rainbowW – wet grass

Z

P(X,Y) = P(X) P(Y) YesP(X | Y, Z) = P(X | Z) Yes

P(X,Y) P(X) P(Y) NoP(X | Y, Z) P(X | Z) No

Are X and Y independent?

Are X and Y conditionally independent given Z?

23

Conditional Independence

• Where are conditional independences here?

Radio and Ignition, given Battery?

Yes

Radio and Starts, given Ignition?

Yes

Gas and Radio, given Battery?

Yes

Gas and Radio, given Starts?

No

Gas and Radio, given nil?

Yes

Gas and Battery, given Moves?

No (why?)

24

Why is this important?

• Helps the developer (or the user) verify the graph structure – Are these things really independent?

– Do I need more/fewer arcs?

• Gives hints about computational efficiencies

• Shows that you understand BNs…

top related