tipy :: prdct :: Prediction :: Class Prediction
[hide private]
[frames] | no frames]

Class Prediction

source code

object --+    
         |    
      list --+
             |
            Prediction

Class for predictions from predictors.

A Prediction instance hold multiple Suggestion instances. It is a list of Suggestion instances and the list is kept ordered according to the suggestions probabilities. Every predictors should return a Preidiction instance.

Class Hierarchy for Prediction
Class Hierarchy for Prediction

Instance Methods [hide private]
new empty list
__init__(self)
Prediction creator.
source code
 
__eq__(self, other)
Override the == operator in order to compare instances.
source code
 
add_suggestion(self, suggestion)
Add a suggestion in the Prediction list.
source code

Inherited from list: __add__, __contains__, __delitem__, __delslice__, __ge__, __getattribute__, __getitem__, __getslice__, __gt__, __iadd__, __imul__, __iter__, __le__, __len__, __lt__, __mul__, __ne__, __new__, __repr__, __reversed__, __rmul__, __setitem__, __setslice__, __sizeof__, append, count, extend, index, insert, pop, remove, reverse, sort

Inherited from object: __delattr__, __format__, __reduce__, __reduce_ex__, __setattr__, __str__, __subclasshook__

Class Variables [hide private]

Inherited from list: __hash__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

Prediction creator.

Returns: new empty list
Overrides: object.__init__

__eq__(self, other)
(Equality operator)

source code 

Override the == operator in order to compare instances.

Two Prediction instances are equal if they contain the same items (thus, have the same length).

Overrides: list.__eq__

add_suggestion(self, suggestion)

source code 

Add a suggestion in the Prediction list.

The suggestion is added at the correct index so that the Prediction list remains ordered.

Note: Using insert() and a while loop seams a little faster than using sorted(). Also, using insort from the bisect module seems to produce similar benchmarks.