MẠNG BAYES

Giới thiệu

Giả sử cần xác định bệnh nhân bị về đường hô hấp. Cần xác định về các triệu chứng sau:

• Bệnh nhân bị ho

• Bệnh nhân bị sốt

• Bệnh nhân khó thở

Không thể chắc chắn 100% bệ nhân bị bệnh về đường hô hấp.

-> Tạo ra sự quyết định không chắc chắn.

1

Giới thiệu

Giả sử chụp X-Quang, quan sát thấy bệnh nhân bị dãn phổi.

-> Khả năng bị bệnh của bệnh nhân cao hơn.

Mạng Bayes (Bayesian Network)

HasAnthrax

HasCough

HasFever

HasDifficultyBreathing

HasWideMediastinum

• Mạng Bayes đã đóng góp trong lĩnh vực AI trong

10 năm nay.

• Đã có nhiều ứng dụng như: lọc thư rác, nhận dạng tiếng nói, robotics, hệ chẩn đoán,…

2

Phân bố xác suất

A

B

C

P(A,B,C)

false false false 0.1

false false true

0.2

false true

false 0.05

false true

true

0.05

true

false false 0.3

true

false true

0.1

true

true

false 0.05

true

true

true

0.15

Sum t = 1

Một số luật xác suất

3

Một số luật xác suất

Một số luật xác suất

4

Một số luật xác suất

Một số luật xác suất

5

Một số luật xác suất

Một số luật xác suất

6

A Bayesian Network

A Bayesian network is made up of:

1. A Directed Acyclic Graph

A

B

C

D

2. A set of tables for each node in the graph

A P(A) A B P(B|A) B D P(D|B) B C P(C|B) 0.6 false 0.01 false 0.02 false 0.4 fals e true 0.4 true 0.99 true 0.98 true 0.6 fals e fals e true false 0.7 fals e fals e true false 0.05 fals e fals e true false 0.9 true true 0.3 true true 0.95 true true 0.1

A Directed Acyclic Graph

Each node in the graph is a random variable

A node X is a parent of another node Y if there is an arrow from node X to node Y eg. A is a parent of B

A

B

C

D

Informally, an arrow from node X to node Y means X has a direct influence on Y

14

7

A Set of Tables for Each Node

Each node Xi has a conditional probability distribution P(Xi | Parents(Xi)) that quantifies the effect of the parents on the node

A P(A) A B P(B|A) 0.6 false 0.01 fals e true 0.4 true 0.99 fals e fals e true false 0.7 true true 0.3

A

The parameters are the probabilities in these conditional probability tables (CPTs)

B

B C P(C|B) false 0.4 true 0.6 fals e fals e true false 0.9 true true 0.1

C

D

B D P(D|B) false 0.02 true 0.98 fals e fals e true false 0.05 true true 0.95

A Set of Tables for Each Node

Conditional Probability Distribution for C given B

For a given combination of values of the parents (B in this example), the entries for P(C=true | B) and P(C=false | B) must add up to 1 eg. P(C=true | B=false) + P(C=false |B=false )=1

If you have a Boolean variable with k Boolean parents, this table has 2k+1 probabilities (but only 2k need to be stored)

16

Weng-Keen Wong, Oregon State University ©2005

8

B C P(C|B) false 0.4 true 0.6 fals e fals e true false 0.9 true true 0.1

The Joint Probability Distribution

Due to the Markov condition, we can compute the joint probability distribution over all the variables X1, …, Xn in the Bayesian net using the formula: n

=

=

=

=

( XP

,...,

X

x

)

( XP

|

Parents

(

X

))

1

x 1

n

n

i

x i

i

= 1

i

Where Parents(Xi) means the values of the Parents of the node Xi with respect to the graph

17

Weng-Keen Wong, Oregon State University ©2005

(cid:213)

Using a Bayesian Network Example Using the network in the example, suppose you want to calculate: P(A = true, B = true, C = true, D = true) = P(A = true) * P(B = true | A = true) *

P(C = true | B = true) P( D = true | B = true)

A

= (0.4)*(0.3)*(0.1)*(0.95)

B

C

D

18

Weng-Keen Wong, Oregon State University ©2005

9

This is from the graph structure

Using a Bayesian Network Example Using the network in the example, suppose you want to calculate: P(A = true, B = true, C = true, D = true) = P(A = true) * P(B = true | A = true) *

P(C = true | B = true) P( D = true | B = true)

A

= (0.4)*(0.3)*(0.1)*(0.95)

B

These numbers are from the conditional probability tables

C

D

19

Weng-Keen Wong, Oregon State University ©2005

Joint Probability Factorization For any joint distribution of random variables the following factorization is always true:

=

CBADPBACPABPAPDCBAP |

)

(

(

)

)

(

(

)

(

,

,

,

,

,

,

|

|

)

We derive it by repeatedly applying the Bayes’ Rule P(X,Y)=P(X|Y)P(Y):

=

,

,

,

,

(

)

(

)

,

|

,

( ) APADCBPDCBAP = =

( )

( (

( (

) ,

, ,

| ,

(

)

|

|

| ) ) APABPABDCP | ) ) ( APABPABCPABCDP

(

(

)

(

)

(

)

,

,

,

|

|

)

| CBADPBACPABPAP

20

10

Joint Probability Factorization

Our example graph carries additional independence information, which simplifies the joint distribution:

=

,

,

(

)

CBADPBACPABPAP |

)

(

(

)

(

)

(

,

,

,

|

|

)

DCBAP , =

BDPBCPABPAP (

)

(

(

)

)

(

|

|

|

)

A

B

This is why, we only need the tables for P(A), P(B|A), P(C|B), and P(D|B) and why we computed P(A = true, B = true, C = true, D = true) = P(A = true) * P(B = true | A = true) *

C

D

P(C = true | B = true) P( D = true | B = true)

= (0.4)*(0.3)*(0.1)*(0.95)

21

Inference

• Using a Bayesian network to compute

probabilities is called inference

• In general, inference involves queries of the

E = The evidence variable(s)

form: P( X | E )

X = The query variable(s)

22

Weng-Keen Wong, Oregon State University ©2005

11

A

Inference Example

B

C

D

Supposed we know that A=true. What is more probable C=true or D=true? For this we need to compute P(C=t | A =t) and P(D=t | A =t). Let us compute the first one.

=

=

=

=

dDtCbBtAP ,

(

,

,

)

=

(

)

db ,

=

=

=

=

tAtCP

(

|

)

=

= tCtAP , = tAP

)

(

tAP

(

)

What is P(A=true)?

A

=

=

=

=

=

=

tAP

(

)

dDcCbBtAP ,

(

,

,

)

B

dcb , , =

=

=

=

=

=

=

=

bBdDPbBcCPtAbBPtAP

(

)

(

)

(

)

(

|

|

|

)

dcb , ,

=

=

=

=

=

=

=

=

tAP

(

)

bBdDPbBcCPtAbBP |

(

(

)

)

(

|

|

)

C

D

dcb , ,

=

=

=

=

=

=

=

=

tAP

(

)

tAbBP

(

|

)

bBdDPbBcCP )

(

(

|

|

)

b

dc ,

=

=

=

=

=

=

=

=

tAP

(

)

tAbBP

(

|

)

bBcCP

(

|

)

bBdDP

(

|

)

b

c

=

=

=

=

=

=

d 1*)

tAP

(

)

tAbBP

(

|

)

bBcCP

(

|

=

=

=

=

=

=

b = tAtBP

(

|

(4.0

c = tBcCP

+= )

(

|

)

BP (

tAf

|

)

= BcCP

(

|

f

))

...

c

A P(A) A B P(B|A) B D P(D|B) B C P(C|B) 0.6 false 0.01 false 0.02 false 0.4 fals e true 0.4 true 0.99 true 0.98 true 0.6 fals e fals e true false 0.7 fals e fals e true false 0.05 fals e fals e true false 0.9 true true 0.3 true true 0.95 true true 0.1

P(A) A B P(B|A) B D C P(C|B)

c P(D|B)

12

A B 0.6 false 0.01 false 0.02 false 0.4 fals e true 0.4 true 0.99 true 0.98 true 0.6 fals e fals e true false 0.7 fals e fals e true false 0.05 fals e fals e true false 0.9 true true 0.3 true true 0.95 true true 0.1

A

What is P(C=true, A=true)?

=

=

=

=

=

=

B

= tCtAP ,

(

)

dDtCbBtAP ,

(

,

,

)

, db

=

=

=

=

=

=

=

=

bBdDPbBtCPtAbBPtAP

)

(

(

)

(

(

)

|

|

|

)

C

D

, db

=

=

=

=

=

=

=

=

tAP

(

)

bBtCPtAbBP )

(

(

|

|

)

bBdDP

(

|

)

b =

=

=

=

=

=

(4.0

tBtCPtAtBP )

(

(

|

|

)

d = tBdDP

(

|

)

d

+

=

=

=

=

=

BP (

BtCPtAf (

)

|

|

= BdDP

(

|

f

))

f

)

d

=

+

=

+

=

=

)1*6.0*7.01*1.0*3.0(4.0

03.0(4.0

)42.0

45.0*4.0

18.0

A P(A) A B P(B|A) B D P(D|B) B C P(C|B) 0.6 false 0.01 false 0.02 false 0.4 fals e true 0.4 true 0.99 true 0.98 true 0.6 fals e fals e true false 0.7 fals e fals e true false 0.05 fals e fals e true false 0.9 true true 0.3 true true 0.95 true true 0.1

Bayesian network

13

Bài tập

Bài tập

14