Constructor

BayesOWL Constructor contains two parts, 'Structure Constructor' and 'Conditional Probability Table Constructor'.

 Structure Constructor

1. Using a BNConstructor

To use the Structure Constructor, you should first import class 'BNConstructor.java, which is contained in package 'umbc.ebiquity.BayesOWL.constructor'.

To build a Bayesian Net, you should provide a list of node names (an array of String), node types (an array of TAG, defined in class 'ExNode.java') and the 'parent-child' relationships (a 2-dimensional String). You can get such required parameters either by using the T-Parser or by your own definition. Then the BN can be constructed:

BNConstructor myBNConstructor = new BNConstructor ();
myBNConstructor.constructBN(nodeNames, tags, parentNodeNames);

Important: length of array nodeNames, tags and relationships should be the same. And each node name relates to a tag and an array of parent node names. For example, node 'nodeNames[i]' has a tag 'tag[i]' and some parents 'parentNodeNames[i]'.

After the Bayesian Net is built, you can use it by calling the 'getNet' method. Also you can store the built BN to your PC by calling the 'saveBNNet' method. For example:

// to get a built BN
Net net = myBNConstructor.getNet();
// to save a BN
myBNConstructor.saveBNNet(Ħ°D:\\somedirectory\\savedNet.dneĦħ);

*Note: BayesOWL Translator will automatically set a series of Conditional Probability Tables for the result BN's nodes. Such CPTs are initialized according to our translation rules. Details can be seen in related research papers.

2. Example

Again take the 'Nature.owl' for example. After using the T-Parser for parsing the ontology, taxonomies can be extracted out. Then you can use BaysOWL Translator to translate it into a Bayesian Net. Whole process is attached following:

Environ NeticaEnv = new Environ(NeticaLicense);
String[] nodeNames = myTParser.getNames();
ExNode.TAG[] tags = myTParser.getTags();
String[][] parentNodeNames = myTParser.getParents();
BNConstructor myBNConstructor = new BNConstructor();
myBNConstructor.constructBN(nodeNames, tags, parentNodeNames);
Net net = myBNConstructor.getNet();
//code for other use of the BN
myBNConstructor.saveBNNet(Ħ°D:\\somedirectory\\savedNet.dneĦħ);
NeticaEnv.finalize();

 CPT Constructor

1. Introduction

BayesOWL CPTConstructor is designed for integrating uncertainty knowledge into Bayesian Nets. It uses our IPFP-based algorithms, e.g. DIPFP, to modify BN nodes' Conditional Probability Tables (CPTs). It iteratively changes CPTs to satisfy probabilities given in constraints and finally integrates uncertainty knowledge into target BN. Details can be seen in our research papers listed in references chapter.

2. Using a CPTConstructor

To use BayesOWL CPTConstructor, you should first import class 'CPTConstructor.java', which is contained in package 'umbc.ebiquity.BayesOWL.constructor'.

You should first provide a Bayesian Net and uncertainty knowledge (represented as probability). Probabilities can be given by parsing probability files, written in a specific format, by BayesOWL P-Parser, see details in Chapter 4, or by user definitions. If you are going to use self-defined probabilities, you should prefer to some pre-defined classes included in package 'umbc.ebiquity.BayesOWL.commonDefine' named 'constraint.java' and its subclasses..

When you have things required in hand, then you can start your integration work with BayesOWL CPTConstructor.

CPTConstructor myCPTConstructor = new CPTConstructor(net, constraint);
myCPTConstructor.run(maxLoops, threshold);

If you have read our research papers carefully, you will find that parameters 'maxLoops' and 'threshold' are the maximum loop number which is an 'integer' and acceptable tolerance which is a 'double' larger than 0 and smaller than 1. When iterative loop number is larger than the 'maxLoops' or tolerance is smaller than the 'threshold', CPTConstructor will stop running and the integration work is done.

Important: If constraint used here is 'conditional', the prior random variable given in probability P(A|L) must contain one and ONLY one variable. This is because we do the integration work on CPTs, and in a BN, one CPT only relates to one node or variable. And in version 1.0, BayesOWL can only deal with consistent situations and complete probabilities.

After integrating uncertainty knowledge, you can use result BN by calling the 'getNet' method. Also you can store the built BN to your PC by calling the 'saveBNNet' method. For example,

// to get a built BN
Net net = myCPTConstructor.getNet();
// to save a BN
myCPTConstructor.saveBNNet(Ħ°D:\\somedirectory\\savedNet.dneĦħ)

Remember that you should need Netica to open the saved result net.

3. Example

Take our 'Nature.owl' example for instance. You have two ways to use BayesOWL Reasoner. If you take the P-Parser results for inputs, using of BayesOWL Reasoner can be in this way:

Environ NeticaEnv = new Environ(NeticaLicense);
Constraint[] myConstraint = myPParser.getConstraint();
CPTConstructor myCPTConstructor = new CPTConstructor(myBNNet, myConstraint);
myCPTConstructor.run(maxLoops, threshold);
Net net = myCPTConstructor.getNet();
//code for other use of the BN
myCPTConstructor.saveBNNet(Ħ°D:\\somedirectory\\savedNet.dneĦħ);
NeticaEnv.finalize();

When you are going to use self-defined constraints, you can do it this way:

Environ NeticaEnv = new Environ(NeticaLicense);
Constraint[] myConstraint = new Constraint[constraintNumber];
//construct your constraints here
CPTConstructor myCPTConstructor = new CPTConstructor(myBNNet, myConstraint);
myCPTConstructor.run(maxLoops, threshold);
Net net = myCPTConstructor.getNet();
//code for other use of the BN
myCPTConstructor.saveBNNet(Ħ°D:\\somedirectory\\savedNet.dneĦħ);
NeticaEnv.finalize();