Package teamwork :: Package math :: Module ProbabilityTree
[hide private]
[frames] | no frames]

Module ProbabilityTree

source code

Defines the layer of probabilistic branches over KeyedTree

Classes [hide private]
  ProbabilityTree
A decision tree that supports probabilistic branches
Functions [hide private]
 
createBranchTree(plane, falseTree, trueTree)
Shorthand for constructing a decision tree with a single branch in it
source code
 
createNodeTree(node=None)
Shorthand for constructing a leaf node with the given value
source code
 
createEqualTree(plane, equalTree, unequalTree)
Shorthand for constructing a decision tree that branches on whether the value lies on the plane or not, with the former/latter cases leading down to the given equalTree/unequalTree
source code
 
createDynamicNode(feature, weights)
Shorthand for constructing a leaf node with a dynamics matrix for the given key with the specified weights (either KeyedVector, or just plain old dictionary, for the lazy)
source code
ProbabilityTree
createANDTree(keyWeights, falseTree, trueTree)
To create a tree that follows the True branch iff both the actor has accepted and the negotiation is not terminated:
source code
ProbabilityTree
createORTree(keyWeights, falseTree, trueTree)
To create a tree that follows the True branch iff either the actor has accepted or the negotiation is not terminated:
source code
ProbabilityTree
identityTree(feature)
Creates a decision tree that will leave the given feature unchanged
source code
Variables [hide private]
  EMPTY_NAMESPACE = None
  EMPTY_PREFIX = None
  StringTypes = (<type 'str'>, <type 'unicode'>)
  XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/'
Function Details [hide private]

createBranchTree(plane, falseTree, trueTree)

source code 

Shorthand for constructing a decision tree with a single branch in it

Parameters:
  • plane (Hyperplane) - the plane to branch on
  • falseTree - the tree that will be followed if the plane tests False
  • trueTree - the tree that will be followed if the plane tests True
  • falseTree,trueTree (ProbabilityTree)

Note: Will not prune tree

createANDTree(keyWeights, falseTree, trueTree)

source code 

To create a tree that follows the True branch iff both the actor has accepted and the negotiation is not terminated:

>>> tree = createANDTree([(StateKey({'entity':'actor','feature':'accepted'}),True), (StateKey({'entity':'self','feature':'terminated'}),False)], falseTree, trueTree)
Parameters:
  • keyWeights ((Key,boolean)[]) - a list of tuples, (key,True/False), of the preconditions for the test to be true
  • falseTree - the tree to invoke if the conjunction evaluates to False
  • trueTree - the tree to invoke if the conjunction evaluates to True
  • falseTree,trueTree (DecisionTree)
Returns: ProbabilityTree
the new tree with the conjunction test at the root

Note: the default truth value of the plane is True (i.e., if no keys are provided, then trueTree is returned

createORTree(keyWeights, falseTree, trueTree)

source code 

To create a tree that follows the True branch iff either the actor has accepted or the negotiation is not terminated:

>>> tree = createORTree([(StateKey({'entity':'actor','feature':'accepted'}),True), (StateKey({'entity':'self','feature':'terminated'}),False)], falseTree, trueTree)
Parameters:
  • keyWeights ((Key,boolean)[]) - a list of tuples, (key,True/False), of the preconditions for the test to be true
  • falseTree - the tree to invoke if the conjunction evaluates to False
  • trueTree - the tree to invoke if the conjunction evaluates to True
  • falseTree,trueTree (DecisionTree)
Returns: ProbabilityTree
the new tree with the conjunction test at the root

Note: the default truth value of the plane is False (i.e., if no keys are provided, then falseTree is returned

identityTree(feature)

source code 

Creates a decision tree that will leave the given feature unchanged

Parameters:
  • feature (str/Key) - the state feature whose dynamics we are creating
Returns: ProbabilityTree