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

Class KeyedPlane

source code

matrices.Hyperplane --+
                      |
                     KeyedPlane

A Hyperplane alternative that stores the weights as a KeyedVector, rather than as a list/array. The interface is identical to that of the Hyperplane superclass, except that the array arguments should be in dictionary (not list/array) form

Instance Methods [hide private]
 
__init__(self, weights, threshold, relation=None)
Constructs a hyperplane whose slope is determined by the given weights (in dictionary or KeyedVector form) and whose intercept is defined by threshold (i.e., weights*x == threshold)
source code
 
simpleThreshold(self, threshold='default')
Returns: a pretty string representation of the threshold
source code
bool
test(self, value)
Returns: True iff the passed in value (in dictionary form) lies above this hyperplane (self.weights*value > self.threshold)
source code
bool→float
testIntervals(self, intervals)
Computes the 'probability' that a point in this region will satisfy this plane.
source code
boolean
always(self, negative=True, probability=False)
Returns: True iff this plane eliminates none of the state space (i.e., for all q, w*q > theta).
source code
bool
isZero(self)
Returns: True iff this plane has zero weights and a zero threshold
source code
Key[]
keys(self)
Returns: the keys used by the weight vector of this plane
source code
 
__neg__(self) source code
 
__eq__(self, other) source code
 
__ge__(self, other) source code
 
__le__(self, other) source code
str
compare(self, other, negative=True)
Modified version of __cmp__ method
source code
 
__sub__(self, other)
Slightly unorthodox subtraction
source code
 
instantiate(self, table) source code
 
instantiateKeys(self, table) source code
str
simpleText(self, numbers=True, all=False)
Returns: a user-friendly string representation of this hyperplane
source code

Inherited from matrices.Hyperplane: __copy__, __deepcopy__, __getitem__, __gt__, __lt__, __setitem__, __str__, __xml__, getConstant, getWeights, inverse, parse

Instance Variables [hide private]
str relation
the relation against this plane.
float threshold
the offset of this plane
KeyedVector weights
the slope of this plane
Method Details [hide private]

__init__(self, weights, threshold, relation=None)
(Constructor)

source code 

Constructs a hyperplane whose slope is determined by the given weights (in dictionary or KeyedVector form) and whose intercept is defined by threshold (i.e., weights*x == threshold)

Parameters:
  • weights (dict) - the slope of the hyperplane
  • threshold - the intercept of this hyperplane
Overrides: matrices.Hyperplane.__init__

Warning: you should start passing in weights in KeyedVector form, because the handling of dict arguments will likely be deprecated

simpleThreshold(self, threshold='default')

source code 
Returns:
a pretty string representation of the threshold

test(self, value)

source code 

Returns true iff the passed in value (in array form) lies above this hyperplane (self.weights*value > self.threshold)

Returns: bool
True iff the passed in value (in dictionary form) lies above this hyperplane (self.weights*value > self.threshold)
Overrides: matrices.Hyperplane.test

testIntervals(self, intervals)

source code 

Computes the 'probability' that a point in this region will satisfy this plane. In reality, just a coarse measure of volume.

Parameters:
  • intervals - a list of dictionaries, each with:
    • weights: the slope of the bounding planes (KeyedVector)
    • lo: the low value for this interval (int)
    • hi: the high value for this interval (int)
Returns: bool→float
a dictionary of probability values over True and False (although not a real Distribution object)

always(self, negative=True, probability=False)

source code 
Parameters:
  • probability - if True, then assume that weights are nonnegative and sum to 1 (default is False)
  • negative - if True, then assume that weights may be negative (default is True)
Returns: boolean
True iff this plane eliminates none of the state space (i.e., for all q, w*q > theta). False iff this plane eliminates all of the state space (i.e., for all q, w*q <= theta).
Overrides: matrices.Hyperplane.always

Warning: guaranteed to hold only within unit hypercube

isZero(self)

source code 
Returns: bool
True iff this plane has zero weights and a zero threshold

keys(self)

source code 
Returns: Key[]
the keys used by the weight vector of this plane

__neg__(self)

source code 
Overrides: matrices.Hyperplane.__neg__

__eq__(self, other)
(Equality operator)

source code 
Overrides: matrices.Hyperplane.__eq__

compare(self, other, negative=True)

source code 

Modified version of __cmp__ method

Parameters:
  • negative - if True, then assume that weights may be negative (default is True)
Returns: str
  • 'less': self < other, i.e., for all x, if not self.test(x), then not other.test(x)
  • 'greater': self > other, i.e., for all x, if self.test(x), then other.test(x)
  • 'equal': self == other, i.e., for all x, self.test(x) == other.test(x)
  • 'inverse': self == not other, i.e., for all x, self.test(x) != other.test(x)
  • 'indeterminate': none of the above
Overrides: matrices.Hyperplane.compare

__sub__(self, other)
(Subtraction operator)

source code 

Slightly unorthodox subtraction

Returns:
a tuple (lo,hi) representing the min/max that the difference between these two planes will be on the unit hypercube

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

source code 
Parameters:
  • numbers (boolean) - if True, floats are used to represent the threshold; otherwise, an automatically generated English representation (defaults to False)
Returns: str
a user-friendly string representation of this hyperplane

Instance Variable Details [hide private]

relation

the relation against this plane. Default is >, alternatives are: =.
Type:
str