Description
LS is short for Lauritzen / Spiegelhalter. The main focus of the LS package is the LS algorithm, which is found in ls.java. The LS algorithm is an inference algorithm that determines the probabilities of node states with or without evidence (instantiated) nodes. (Please see our references.) LS can either be run graphically or from the command line, as appears below.
Examples
==============================LSExample.java===================================== import bbn.*; import java.util.Vector; public class LSExample { public static void main(String[] args){ System.out.println("load the network from file ... "); BBN network = new BBN(); network.loadFromXML("asia.xml");
NodeManager manager = new NodeManager(network); LS lsObject = new LS(manager, "evidence.txt");
System.out.println(lsObject.report());
} }
==============================evidence.txt=====================================
1 0 0 0 0 0 1 visit to Asia?|smoking?|tuberculosis?|lung cancer?|either tub. or lung cancer?|bronchitis?|positive X-ray?|dyspnoea? a2 f1 b2 e2 c2 g2 d2 h2
The format of evidence files for the time being is very crude. We hope to convert it to an XML format for the next release. The format is as follows:
Line 1: Evidence bit vector. Determines which nodes will be used as evidence nodes. In this example, visit to Asia? and dyspnoea? are being set to evidence nodes.
Line 2: Node order. Used to determine what the following node state names correspond to.
Line 3 through Line n: Node states. Each line consists of a set instantiation. The non-evidence node values are only important if you want to judge the likelihood of the entire set, which you can use bbn.NodeManager.getStateSetProbability() to find out.