0% found this document useful (0 votes)
3 views6 pages

Tutorial 1

This document is a tutorial on Bayesian Networks, detailing their qualitative and quantitative representations, including the construction of Directed Acyclic Graphs (DAGs) and conditional probability tables. It covers the variables involved, their domains, and provides examples of probability distributions and calculations. The tutorial concludes by summarizing the key concepts of constructing and verifying Bayesian Networks.

Uploaded by

raniimalouii
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views6 pages

Tutorial 1

This document is a tutorial on Bayesian Networks, detailing their qualitative and quantitative representations, including the construction of Directed Acyclic Graphs (DAGs) and conditional probability tables. It covers the variables involved, their domains, and provides examples of probability distributions and calculations. The tutorial concludes by summarizing the key concepts of constructing and verifying Bayesian Networks.

Uploaded by

raniimalouii
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Artificial Intelligence

Lab Tutorial 1 Correction


Bayesian Networks
Student Solution
2025–2026

1 Qualitative Representation
A Bayesian Network is represented by a Directed Acyclic Graph (DAG) where:

• Nodes represent random variables

• Arcs represent probabilistic dependencies

The variables used in this tutorial are:

• Age

• Sex

• Education

• Occupation

• Residence

• Travel

1.1 DAG1 : Manual construction


Example of arcs added manually:

Age → Education

Education → Occupation

Occupation → T ravel

1
Residence → T ravel

Sex → Occupation
Graphical representation:

Age

Education

Sex Occupation Residence

Travel

1.2 DAG2 : Matrix representation


The same structure can be represented using an adjacency matrix.
 
0 1 0 0 0 0
0 0 1 0 0 0
 
0 0 0 1 0 0
M = 0 0

 0 0 0 0 
0 0 1 0 0 0
0 0 0 1 0 0
Where the order of variables is:

(Age, Education, Occupation, T ravel, Sex, Residence)


If both DAGs represent the same dependencies then:

[Link](DAG1, DAG2) = T RU E

2
1.3 Cycle Test
A Bayesian Network must be acyclic.
If we try to add:

T ravel → Age
we obtain a cycle:

Age → Education → Occupation → T ravel → Age


Typical error message in R:
Error: the resulting graph contains cycles

2 Quantitative Representation
All variables are discrete.

2.1 Variable Domains


• Age = {young, adult, old}

• Sex = {male, female}

• Education = {HighSchool, University}

• Occupation = {Employee, SelfEmployed}

• Residence = {Small, Large}

• Travel = {Car, Train, Other}

3 Joint Probability Distribution


For a Bayesian Network the joint distribution is:

P (Age, Sex, Education, Occupation, Residence, T ravel)


Using the DAG factorization:

P (A, S, E, O, R, T ) = P (A) P (S) P (R) P (E|A) P (O|E, S) P (T |O, R)

3
4 Example Probability Tables
4.1 Prior probability of Age
P (Age)

Age Probability
young 0.4
adult 0.4
old 0.2

4.2 Probability of Sex


Sex Probability
male 0.5
female 0.5

4.3 Education given Age


P (Education|Age)

Age HighSchool University


young 0.7 0.3
adult 0.4 0.6
old 0.6 0.4

4.4 Occupation given Education and Sex


P (Occupation|Education, Sex)

Education Sex Employee SelfEmployed


HS male 0.7 0.3
HS female 0.8 0.2
Uni male 0.6 0.4
Uni female 0.7 0.3

4.5 Residence
City size Probability
Small 0.55
Large 0.45

4
4.6 Travel given Occupation and Residence
P (T ravel|Occupation, Residence)

Occupation Residence Car Train Other


Employee Small 0.6 0.2 0.2
Employee Large 0.3 0.5 0.2
SelfEmp Small 0.7 0.1 0.2
SelfEmp Large 0.4 0.4 0.2

5 Venn Diagram Interpretation


The joint probability can also be visualized using sets.

Age Education

Occupation

The intersection represents joint events such as:

P (Age = young ∩ Education = U niversity)


Using conditional probability:

P (A ∩ E) = P (A)P (E|A)
Example calculation:

P (young ∩ university)

= P (young) × P (university|young)

= 0.4 × 0.3

= 0.12

5
6 Complete Bayesian Network
The final Bayesian Network is obtained by combining:

• The DAG structure

• All conditional probability tables

Thus the model fully defines the probability distribution of the system.

P (A, S, E, O, R, T ) = P (A)P (S)P (R)P (E|A)P (O|E, S)P (T |O, R)

7 Conclusion
This tutorial demonstrated:

• Construction of Bayesian Network DAGs

• Verification of identical structures

• Detection of cycles

• Construction of conditional probability tables

• Computation of joint probabilities

You might also like