Bài giảng Nhập môn trí tuệ nhân tạo - Chương 6: Mạng Bayes trình bày các nội dung: Giới thiệu mạng Bayes, phân bố xác suất, một số luật phân bố xác suất, the joint probability distribution, using a bayesian network example,... Mời các bạn tham khảo.
Trang 1Gi ớ 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
Trang 2Gi ớ 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)
• 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,…
HasAnthrax
HasCough HasFever HasDifficultyBreathing HasWideMediastinum
Trang 3false 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
Trang 4M ộ t s ố lu ậ t xác su ấ t
M ộ t s ố lu ậ t xác su ấ t
Trang 5M ộ t s ố lu ậ t xác su ấ t
M ộ t s ố lu ậ t xác su ấ t
Trang 6M ộ t s ố lu ậ t xác su ấ t
M ộ t s ố lu ậ t xác su ấ t
Trang 7A Bayesian Network
A Bayesian network is made up of:
A P(A)
fals
e
0.6
true 0.4
A
B
A B P(B|A)
fals e false 0.01 fals
e true 0.99 true false 0.7 true true 0.3
B C P(C|B)
fals e false 0.4 fals
e true 0.6 true false 0.9 true true 0.1
B D P(D|B)
fals e false 0.02 fals
e true 0.98 true false 0.05 true true 0.95
1 A Directed Acyclic Graph
2 A set of tables for each node in the graph
14
A Directed Acyclic Graph
A
B
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
Informally, an arrow from
node X to node Y means X
has a direct influence on Y
Trang 8A Set of Tables for Each Node
Each node X ihas a conditional probability
distribution P(X i | Parents(X i)) that quantifies the effect of the parents on the node The parameters are the probabilities in these conditional probability tables (CPTs)
A P(A)
fals
e
0.6
true 0.4
A B P(B|A)
fals e false 0.01 fals
e true 0.99 true false 0.7 true true 0.3
B C P(C|B)
fals
e
false 0.4
fals
e
true 0.6
true false 0.9
true true 0.1
B D P(D|B)
fals e false 0.02 fals
e true 0.98 true false 0.05 true true 0.95
A
B
A Set of Tables for Each Node
Conditional Probability
Distribution for C given B
If you have a Boolean variable with k Boolean parents, this table
has 2k+1probabilities (but only 2kneed to be stored)
B C P(C|B)
fals
e
false 0.4
fals
e
true 0.6
true false 0.9
true true 0.1 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
Trang 9Weng-Keen Wong, Oregon State University ©2005 17
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:
∏
=
=
=
=
i
i i
i n
X x
X
P
1 1
(
Where Parents(Xi) means the values of the Parents of the node Xi
with respect to the graph
Weng-Keen Wong, Oregon State University ©2005 18
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)
B
Trang 10Weng-Keen Wong, Oregon State University ©2005 19
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)
B
This is from the graph structure
These numbers are from the
conditional probability tables
Joint Probability Factorization
For any joint distribution of random variables the
following factorization is always true:
We derive it by repeatedly applying the Bayes’ Rule
P(X,Y)=P(X|Y)P(Y):
) , ,
| ( ) ,
| ( )
| ( )
(
) ( )
| ( ) ,
| ( ) , ,
| (
) ( )
| ( ) ,
| , (
) ( )
| , , ( ) , , ,
(
C B A D P B A C P A B P A
P
A P A B P A B C P A B C D
P
A P A B P A B D C
P
A P A D C B P D C B A
P
=
=
=
) , ,
| ( ) ,
| ( )
| ( ) ( ) ,
,
,
( A B C D P A P B A P C A B P D A B C
Trang 1121
Joint Probability Factorization
A
B
)
| ( )
| ( )
| (
)
(
) , ,
| ( ) ,
| ( )
| ( ) ( ) ,
,
,
(
B D P B C P A B
P
A
P
C B A D P B A C P A B P A P D
C
B
A
P
=
=
Our example graph carries additional independence
information, which simplifies the joint distribution:
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) *
P(C = true | B = true) P( D = true | B = true)
= (0.4)*(0.3)*(0.1)*(0.95)
Weng-Keen Wong, Oregon State University ©2005 22
Inference
• Using a Bayesian network to compute
probabilities is called inference
• In general, inference involves queries of the
form:
P( X | E )
X = The query variable(s)
E = The evidence variable(s)
Trang 12Inference Example
A P(A)
fals
e
0.6
true 0.4
A
B
A B P(B|A)
fals e false 0.01 fals
e true 0.99 true false 0.7 true true 0.3
B C P(C|B)
fals e false 0.4 fals
e true 0.6 true false 0.9 true true 0.1
B D P(D|B)
fals e false 0.02 fals
e true 0.98 true false 0.05 true true 0.95
) (
) , , , ( )
(
) , ( )
|
t A P
d D t C b B t A P t
A P
t C t A P t
A
t
C
=
=
=
=
=
=
=
=
=
=
=
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
What is P(A=true)?
A P(A)
fals
e
0.6
true 0.4
A
B
A B P(B|A)
fals e false 0.01 fals
e true 0.99 true false 0.7
B C P(C|B)
fals e false 0.4 fals
e true 0.6 true false 0.9
B D P(D|B)
fals e false 0.02 fals
e true 0.98 true false 0.05
))
| ( )
| ( )
| ( )
|
(
(
4
.
0
1 )
| ( )
| (
)
(
)
| ( )
| ( )
| (
)
(
)
| ( )
| ( )
| (
)
(
)
| ( )
| ( )
| (
)
(
)
| ( )
| ( )
| (
)
(
) , , , (
)
(
, ,
,
,
=
=
=
=
= +
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
∑
∑
∑
∑
∑
∑
∑
∑
∑
∑
∑
∑
f B c C P t A f B P t B c C P t A
t
B
P
b B c C P t A b B P
t
A
P
b B d D P b B c C P t A b B P
t
A
P
b B d D P b B c C P t A b B P
t
A
P
b B d D P b B c C P t A b B P
t
A
P
b B d D P b B c C P t A b B P
t
A
P
d D c C b B t A P
t
A
P
c c
c b
d c
b
d b
d
b
d
b
d
b
Trang 13What is P(C=true, A=true)?
A P(A)
fals
e
0.6
true 0.4
A
B
A B P(B|A)
fals e false 0.01 fals
e true 0.99 true false 0.7 true true 0.3
B C P(C|B)
fals e false 0.4 fals
e true 0.6 true false 0.9 true true 0.1
B D P(D|B)
fals e false 0.02 fals
e true 0.98 true false 0.05 true true 0.95
18 0 45 0
* 4 0 ) 42 0 03 0 ( 4 0 ) 1 6 0
* 7 0 1 1
0
*
3
0
(
4
0
))
| ( )
| ( )
|
(
)
| ( )
| ( )
|
(
(
4
0
)
| ( )
| ( )
| ( )
(
)
| ( )
| ( )
| ( )
(
) , , , ( )
,
(
,
,
=
= +
= +
=
=
=
=
=
=
=
+
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
∑
∑
∑
∑
∑
∑
f B d D P f B t C P t A
f
B
P
t B d D P t B t C P t A t
B
P
b B d D P b B t C P t A b B P
t
A
P
b B d D P b B t C P t A b B P
t
A
P
d D t C b B t A P t
C
t
A
P
d d
d b
d
d
Bayesian network
Trang 14Bài t ậ p