Simple file format
The file format simple is used to describe belief networks. Files typically have the ending .simple.
Structure
A file in the simple format starts with the prologue:
network Unknown f lsb e <evidence?> <#evidence> <#variables>
where
<evidence?> is either yes or no, signalling whether this particular belief network instance has evidence attached or not,
<#evidence> is the number of variables that are evidence, i.e. an integer,
<#variables> is the total number of variables, i.e. an integer.
The prologue is followed by the variable specifications, one line for each variable, each of the following format:
v <variable> <domainsize> <evidence> <#parents> <name>
if the instance has evidence attached or
v <variable> <domainsize> <#parents> <name>
if there is no evidence (as specified in the prologue), where
<variable> is the index of the variable (counting incrementally from 0), i.e. an integer,
<domainsize> is the size of the respective variable's domain, i.e. an integer,
<evidence>, if applicable, is the value of the evidence, indexed from 0 to <domainsize>-1, i.e. an integer, -1 if variable is not part of evidence,
<#parents> is the number of parents in the belief network, i.e. an integer,
<name> is the name associated with the variable, i.e. a string.
The block of variable specifications is followed by the conditional probability distributions for the variable, which consist of two lines for each variable's distribution. The format is as follows:
p <v_0> <v_1> ... <v_n> <v> <value for 1st tuple> <value for 2nd tuple> ... <value for last tuple>
where <v_0> to <v_n> and <v> signal that the probability distribution P(v | v_0,...,v_n) will be specified in the next line. The <v_i> and <v> are the respective variable's index, as specified earlier in the file. The actual distribution table is then given as the enumeration of probabities for the different tuples in ascending order, starting with the tuple that assigns the first value to each variable's domain (see example below).
Example
Take a simple belief network with three variables X, Y, and Z with domains {0,1}, {0,1}, and {0,1,2}, respectively. Let the joint probability be given by P(X,Y,Z) = P(X) P(Y|X) P(Z|Y).
We assume the following conditional probability tables:
X |
P(X) |
|
0 |
0.436 |
|
1 |
0.564 |
|
X |
Y |
P(Y|X) |
0 |
0 |
0.128 |
0 |
1 |
0.872 |
1 |
0 |
0.920 |
1 |
1 |
0.080 |
Y |
Z |
P(Z|Y) |
0 |
0 |
0.210 |
0 |
1 |
0.333 |
0 |
2 |
0.457 |
1 |
0 |
0.811 |
1 |
1 |
0.000 |
1 |
2 |
0.189 |
Given the evidence Y = 1 we could write a file in simple format as follows:
network Unknown f lsb e yes 1 3 v 0 2 -1 0 X v 1 2 1 1 Y v 2 3 -1 1 Z p 0 0.436 0.564 p 0 1 0.128 0.872 0.920 0.080 p 1 2 0.210 0.333 0.457 0.811 0.000 0.189
Conversion from other formats
To convert problems from the common XBIF format to the simple format, you can use this Python script. A description of the XBIF format is available here.
