CFEngine API

org.recommender.algorithms.Experimental
Class DecisionTree

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

public class DecisionTree
extends java.lang.Object

Helps parse a decision tree by processing begin/end element events. Stores a representation of the decision tree in memory.

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

Field Summary
(package private)  org.recommender.algorithms.Experimental.DecisionTree.Branch currBranch
           
(package private)  Multinomial currMultinomial
           
(package private)  org.recommender.algorithms.Experimental.DecisionTree.Vertex currVertex
          Keep track of current position in the tree, as it is built.
(package private)  org.recommender.algorithms.Experimental.DecisionTree.Vertex headVertex
          Top level vertex, before any branches.
(package private)  java.util.ArrayList inputVars
          ArrayList of input variable names
(package private)  java.util.HashMap inputVarStates
          HashMap of LinkedLists of state indices for the input variables
 
Constructor Summary
DecisionTree()
          Construct a DecisionTree with the given input variables.
 
Method Summary
 void beginBranch()
          Method called when a <Branch> tag is encountered.
 void beginMultinomial()
          Method called when a <Multinomial> tag is encountered.
 void beginVertex(StartElementEvent vertex)
          Method called when a <Vertex> tag is encountered.
 void endBranch()
          Method called when a </Branch> tag is encountered.
 void endProbs(java.lang.String probs)
          Method called when a </Probs> tag is encountered.
 void endValues(java.lang.String values)
          Method called when a </Values> tag is encountered.
 void endVertex()
          Method called when a </Vertex> tag is encountered.
 float getProb(int state, int[] allStates)
          Returns the probability that this variable is in a specified state, given the states of all other variables in the network.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inputVars

java.util.ArrayList inputVars
ArrayList of input variable names


inputVarStates

java.util.HashMap inputVarStates
HashMap of LinkedLists of state indices for the input variables


headVertex

org.recommender.algorithms.Experimental.DecisionTree.Vertex headVertex
Top level vertex, before any branches. (Note: some decision trees have no vertices at all; in such cases, this is null.)


currVertex

org.recommender.algorithms.Experimental.DecisionTree.Vertex currVertex
Keep track of current position in the tree, as it is built.


currBranch

org.recommender.algorithms.Experimental.DecisionTree.Branch currBranch

currMultinomial

Multinomial currMultinomial
Constructor Detail

DecisionTree

public DecisionTree()
Construct a DecisionTree with the given input variables.

Method Detail

getProb

public float getProb(int state,
                     int[] allStates)
Returns the probability that this variable is in a specified state, given the states of all other variables in the network.

Parameters:
state - the potential state of this decision tree's variable.
allStates - array of integers specifying the state of each other variable. allStates[i] = the state of variable i.
Returns:
prob

beginVertex

public void beginVertex(StartElementEvent vertex)
Method called when a <Vertex> tag is encountered. Creates a new vertex as the child of the current branch.

Parameters:
vertex -

endVertex

public void endVertex()
Method called when a </Vertex> tag is encountered. Ends the current vertex and moves up in the tree.


beginBranch

public void beginBranch()
Method called when a <Branch> tag is encountered. Creates a new branch as the child of the current vertex.


endValues

public void endValues(java.lang.String values)
Method called when a </Values> tag is encountered. Sets the values of the current branch to those provided.

Parameters:
values -

endBranch

public void endBranch()
Method called when a </Branch> tag is encountered.


beginMultinomial

public void beginMultinomial()
Method called when a <Multinomial> tag is encountered.


endProbs

public void endProbs(java.lang.String probs)
Method called when a </Probs> tag is encountered.

Parameters:
probs - pcdata contents of the <Probs> tag.

CFEngine API

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