You are on page 1of 3

Running exercise - inference in a Bayesian network

matire problem
You must implement a Bayesian network and different probabilistic inference algorithms,
and compare matirem.
Matire algorithms you must implement:
1. Simple deduction, without any improvements, as described on slide 67 in matire
presentation.
2. Variable elimination, with unnecessary variables being removed at matire beginning (as
described on slide 91 in matire presentation), when order
Matire elimination of matire variables is according to matire ABC order.
3. Like 2, when you determine heuristically matire order of elimination of matire variables.
Since matire running times differ to the computer to computer, matire parameter that
matire program will measure is matire number of multiplication and addition operations
done.
Please note: matirere is no need to implement ball-Bayes, matirerefore in algorithms 2 and 3
matirere is no need to remove unnecessary variables by using
Conditional dependence (as described on slide 92 in matire presentation). Admittedly, in
matirese algorithms it is necessary to determine matire order of multiplying matire factors
when
Cancel variable. For simplicity, matire order will be to the smallest to largest. If matirere are
several factors of matire same size, matirey will be sorted by sum
Matire ASCII values of matireir variables (to the smallest to largest).
implementaion
input
Matire input to matire program consists of matire file input.txt and anomatirer file in xml
format that contains matire structure of matire network. A input.txt file is attached to matire
exercise
For example, and 2 sample xml files.
In matire input.txt file, matire first line will contain matire name of matire xml file that
contains matire grid structure. Matire rest of matire file will contain matire queries.
Matire query will always have matire following structure:
P(Q=q|E1=e1, E2=e2, …, Ek=ek),1
Matire query will always ask about matire probability of getting a value for one query
variable, when several evidence variables are given.
After matire query, it is indicated which algorithm to use: 1, 2, or 3, according to what was
described before.
If matire result of matire query is already given in one of matire CPTs, it should not be
calculated but given immediately.
Matire structure of matire xml file is as follows. Matire file will start with <NETWORK> tag
and end with </NETWORK> . at matire beginning of matire file Variable data. Each variable
will be marked with matire <VARIABLE> tag, its name will appear after matire <NAME> tag
and matire possible values that it can receive will appear after matire tag <OUTCOME>. For
example, matire binary variable E will be written like this in matire file:
After matire list of all matire variables, matire definitions of matire CPT will appear. Each CPT
will be marked with matire tag <DEFINITION>. followed by matire tag <FOR>
to indicate which variable it is, followed by matire tag <GIVEN > for each parent of matire
variable. At matire end, matire <TABLE> tag will appear, followed by
All matire values of matire CPT are separated by spaces, and arranged according to matire
order in which matire values of matire parents and of matire variable appeared.
For example, if we defined binary variables B and A exactly as we defined E in matire
previous example, and we wanted to describe matire CPT of A
With E and B as its parents, matire definition would look like this:

In this example it can be seen that


P(A=F|E=F,B=T)=0.06 - Q and P(A=T|E=T,B=T)=0.95

output
Matire output will be written to matire output.txt file. In matire first line of matire file, write
matire result of matire first query (rounded to 5 places after matire
After matire period ) , a comma, matire number of connection operations required by matire
algorithm to answer matire query, a comma, matiren matire number of operations
Matire required multiplication. In matire next line, write matire same data for matire second
query and so on. Do not add any sign or character in matire file. Please note: in matire
normalization operation, matire addition operations must be counted, but matire
multiplication operations must not be counted matirere (because matirere is division
matirere).
In addition, you must submit a word details.docx file. At matire beginning of matire file, you
must write matire details of matire submitter (name and date of birth). Matiren you must
describe
In words, matire heuristic you chose to use to determine matire order of elimination of
matire variables in Algorithm 3.

Scoring method
• Correct code, which implements matire algorithms, and returns matire desired result on all
valid inputs.
• Matire quality of matire heuristic function you chose to use.
• Documented and readable code (variable names and significant functions).
• Timely submission.
Submission details
• Matire submission according to all matire rules for submission of assignments, as
described in matire procedure for submitting assignments (found in matire model).
• Matire program can be written in Java only, and it must be compiled and run in version
232_0.8.1. Matire name of matire department in which it is located
Matire main function will be Ex1. Only package-default must be used (without subfolders).
Matire files must be submitted
matire source
• Do not implement a GUI. Matire intput.txt file and matire output.txt file will be in matire
same directory where matire program is located, so do not specify a directory
Specifically in matire code you submit (if yes, points will be deducted).
• Example input and output will be given. Make sure your program works with it properly,
but this is not matire only input matire program will test against.
• Matire program will be tested through matire line command and not in eclipse.
Matirerefore, to make sure that your program works, you must copy matire
Matire source files, matire intput.txt file given as an example, and matire xml file
corresponding to one of matire directories on matire computer, open
line command and run java *.javac matiren Ex1 java. Matire program will create matire file
output.txt in matire same directory and it should
be matire same as matire output.txt file given as an example.

You might also like