CFEngine API

org.recommender.algorithms.Experimental
Class ContinuousBayesNet

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

public class ContinuousBayesNet
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
           
(package private)  java.util.List[] children
           
(package private)  java.lang.Integer currVariable
           
(package private)  ContinuousDecisionTree[] decisionTrees
           
(package private)  ContinuousDecisionTree dtree
           
(package private)  java.lang.StringBuffer elementCdata
           
(package private)  boolean inCdata
           
(package private)  boolean inDecisionTree
           
(package private)  java.io.PrintStream out
           
(package private)  DocumentParser parser
           
 
Constructor Summary
ContinuousBayesNet(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, float state, float[] 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

inCdata

boolean inCdata

elementCdata

java.lang.StringBuffer elementCdata

cdataCdata

java.lang.StringBuffer cdataCdata

decisionTrees

ContinuousDecisionTree[] decisionTrees

dtree

ContinuousDecisionTree dtree

currVariable

java.lang.Integer currVariable

children

java.util.List[] children
Constructor Detail

ContinuousBayesNet

public ContinuousBayesNet(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,
                     float state,
                     float[] 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.


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