CFEngine API

org.recommender.algorithms.Experimental
Class BayesNet

java.lang.Object
  |
  +--org.recommender.algorithms.Experimental.BayesNet

public class BayesNet
extends java.lang.Object

In-memory representation of a Bayesian network with decision trees at each node. Includes functionality to load a Bayesian network from a file, and for this reason implements the Application interface from the XP XML parser. It also depends on the xp.jar library. Methods that lack comments are the implementation of the Application interface. These are effectively callbacks, made public so that they're accessible to the XP parser.

Author:
Daniel Lowd <dlowd@cs.orst.edu>

Field Summary
(package private)  java.lang.StringBuffer cdataCdata
          Character data found in the contents of a CDATA section.
(package private)  java.util.List[] children
          Child lists (linked lists of Integers)
(package private)  java.lang.Integer currVariable
           
(package private)  DecisionTree[] decisionTrees
          Decision trees
(package private)  DecisionTree dtree
           
(package private)  java.lang.StringBuffer elementCdata
          Character data found in the contents of an element.
(package private)  boolean inCdata
          Keep track of our state in the XML file
(package private)  boolean inDecisionTree
          Keep track of our state in the XML file
(package private)  java.io.PrintStream out
           
(package private)  DocumentParser parser
           
 
Constructor Summary
BayesNet(int maxVar, java.lang.String filename)
          Construct a new Bayesian network.
 
Method Summary
 void characterData(CharacterDataEvent characterData)
           
 void comment(CommentEvent e)
           
 void endCdataSection(EndCdataSectionEvent e)
           
 void endDocument()
           
 void endDocumentTypeDeclaration(EndDocumentTypeDeclarationEvent e)
           
 void endElement(EndElementEvent endElement)
           
 void endEntityReference(EndEntityReferenceEvent e)
           
 void endProlog(EndPrologEvent e)
           
 java.util.Iterator getChildren(int var)
          Get an iterator of all children of the specified variable.
 float getProb(int var, int state, int[] allStates)
          Get the probability that a specified variable is in a specified state given the state of every other variable.
 void load(java.io.InputStream in)
          Begin parsing an xmod file from the specified InputStream.
 void markupDeclaration(MarkupDeclarationEvent e)
           
 void processingInstruction(ProcessingInstructionEvent e)
           
 void startCdataSection(StartCdataSectionEvent e)
           
 void startDocument()
           
 void startDocumentTypeDeclaration(StartDocumentTypeDeclarationEvent e)
           
 void startElement(StartElementEvent startElement)
           
 void startEntityReference(StartEntityReferenceEvent e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parser

DocumentParser parser

out

java.io.PrintStream out

inDecisionTree

boolean inDecisionTree
Keep track of our state in the XML file


inCdata

boolean inCdata
Keep track of our state in the XML file


elementCdata

java.lang.StringBuffer elementCdata
Character data found in the contents of an element.


cdataCdata

java.lang.StringBuffer cdataCdata
Character data found in the contents of a CDATA section.


decisionTrees

DecisionTree[] decisionTrees
Decision trees


dtree

DecisionTree dtree

currVariable

java.lang.Integer currVariable

children

java.util.List[] children
Child lists (linked lists of Integers)

Constructor Detail

BayesNet

public BayesNet(int maxVar,
                java.lang.String filename)
Construct a new Bayesian network.

Parameters:
maxVar - highest variable index used by the network. This could be inferred from the file, but it's easier if it's known ahead of time.
filename - path and filename of the Bayesian network model. The expected file format is .xmod, as output by the WinMine toolkit, with decision trees at each node.
Method Detail

getChildren

public java.util.Iterator getChildren(int var)
Get an iterator of all children of the specified variable.

Parameters:
var - index of the variable whose children we want.

getProb

public float getProb(int var,
                     int state,
                     int[] allStates)
Get the probability that a specified variable is in a specified state given the state of every other variable.

Parameters:
var - index of the variable in question
state - variable state of which to calculate the probability
allStates - array containing the state of each variable in this network. Simply returns the approviate value from the variable's probability distribution in its decision tree. This method does not do inference, not even Markov-blanket inference. The caller is expected to implement that.

load

public void load(java.io.InputStream in)
Begin parsing an xmod file from the specified InputStream.

Parameters:
in - input xmod file

startDocument

public void startDocument()

endProlog

public void endProlog(EndPrologEvent e)

startElement

public void startElement(StartElementEvent startElement)

characterData

public void characterData(CharacterDataEvent characterData)

endElement

public void endElement(EndElementEvent endElement)

endDocument

public void endDocument()

startCdataSection

public void startCdataSection(StartCdataSectionEvent e)

endCdataSection

public void endCdataSection(EndCdataSectionEvent e)

processingInstruction

public void processingInstruction(ProcessingInstructionEvent e)

comment

public void comment(CommentEvent e)

startEntityReference

public void startEntityReference(StartEntityReferenceEvent e)

endEntityReference

public void endEntityReference(EndEntityReferenceEvent e)

startDocumentTypeDeclaration

public void startDocumentTypeDeclaration(StartDocumentTypeDeclarationEvent e)

endDocumentTypeDeclaration

public void endDocumentTypeDeclaration(EndDocumentTypeDeclarationEvent e)

markupDeclaration

public void markupDeclaration(MarkupDeclarationEvent e)

CFEngine API

Copyright © 2003 - Oregon State University www.orst.edu