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

Class KeyedTree

source code

matrices.DecisionTree --+
                        |
                       KeyedTree
Known Subclasses:

A DecisionTree that requires KeyedPlane branches.

Nested Classes [hide private]
  planeClass
the class used to instantiate the branches
Instance Methods [hide private]
 
fill(self, keys, value=0.0)
Fills in any missing slots with a default value
source code
dict:Key→boolean
_keys(self)
Helper method for keys
source code
 
freeze(self)
Locks in the dimensions and keys of all leaves
source code
 
unfreeze(self)
Unlocks the dimensions and keys of all leaves
source code
str
simpleText(self, printLeaves=True, numbers=True, all=False)
Returns a more readable string version of this tree
source code
 
updateKeys(self)
Updates the record of contained keys in self.keys
source code
 
instantiate(self, table) source code
 
instantiateKeys(self, table)
Replaces any key references by the values in the table
source code
 
_instantiate(self, table) source code
 
_multiply(self, other, comparisons=None, conditions=[]) source code
 
scale(self, factor)
Scales all of the leaf nodes by the given float factor
source code
 
getKeys(self)
Returns: a list of any keys used by at least one branch in this tree
source code
str
toNumeric(self)
Returns: a string representation of the internal array representation
source code
int
pruneIdentities(self)
Replaces any identity matrices at the leaves of this tree with the number 1.
source code
 
__getitem__(self, index) source code

Inherited from matrices.DecisionTree: __add__, __copy__, __eq__, __hash__, __init__, __mul__, __neg__, __str__, __sub__, __xml__, branch, branches, children, count, createIndex, depth, fromRules, generateAlternatives, getPath, getValue, isLeaf, leafNodes, leaves, makeLeaf, makeRules, merge, parse, prune, rebalance, removeTautologies, replace

Inherited from matrices.DecisionTree (private): _extractTree, _merge

Class Variables [hide private]

Inherited from matrices.DecisionTree: checkPrune, checkTautology

Instance Variables [hide private]
Key[]
keys(self)
the cumulative list of keys used by all of the branches below
source code
Method Details [hide private]

fill(self, keys, value=0.0)

source code 

Fills in any missing slots with a default value

Parameters:
  • keys (list of Key instances) - the slots that should be filled
  • value - the default value (defaults to 0)

Note: does not overwrite existing values

_keys(self)

source code 

Helper method for keys

Returns: dict:Key→boolean
all keys used in this tree and all subtrees and leaves

simpleText(self, printLeaves=True, numbers=True, all=False)

source code 

Returns a more readable string version of this tree

Parameters:
  • printLeaves (boolean) - optional flag indicating whether the leaves should also be converted into a user-friendly string
  • numbers (boolean) - if True, floats are used to represent the threshold; otherwise, an automatically generated English representation (defaults to False)
Returns: str

_multiply(self, other, comparisons=None, conditions=[])

source code 
Overrides: matrices.DecisionTree._multiply

getKeys(self)

source code 
Returns:
a list of any keys used by at least one branch in this tree

toNumeric(self)

source code 
Returns: str
a string representation of the internal array representation

pruneIdentities(self)

source code 

Replaces any identity matrices at the leaves of this tree with the number 1.

Returns: int
the number of identity matrices found

__getitem__(self, index)
(Indexing operator)

source code 
Overrides: matrices.DecisionTree.__getitem__

Instance Variable Details [hide private]

keys(self)

source code 
the cumulative list of keys used by all of the branches below
Returns: Key[]
all keys used in this tree and all subtrees and leaves