Package sentence :: Module ranking :: Class Ranking
[hide private]
[frames] | no frames]

Class Ranking

source code

object --+    
         |    
      list --+
             |
            Ranking

Class that wraps the functionality of a ranking list. It behaves as normal list but also allows additional functions to be performed, that are relevant to ranking

Instance Methods [hide private]
new empty list
__init__(self, ranking, **kwargs)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__setitem__(self, key, value)
x[i]=y
source code
 
__delitem__(self, key)
del x[y]
source code
 
normalize(self, **kwargs)
Create a new normaliyed ranking out of a messy ranking like [1,3,5,4] to [1,2,4,3]
source code
[int, ...]
indexes(self, neededrank)
Returns the indexes of the particular ranks in the list
source code
Ranking
inverse(self, **kwargs)
Created an inverted ranking, so that the best item becomes worse
source code
Ranking
integers(self)
Return a version of the ranking, only with integers.
source code

Inherited from list: __add__, __contains__, __delslice__, __eq__, __ge__, __getattribute__, __getitem__, __getslice__, __gt__, __iadd__, __imul__, __iter__, __le__, __len__, __lt__, __mul__, __ne__, __new__, __repr__, __reversed__, __rmul__, __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__

Instance Variables [hide private]
  list
the ranking
  normalization
describes what kind of normalization has been been performed to the internal list
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, ranking, **kwargs)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • ranking (list of floats, integers or strings) - a list of values representing a ranking
Returns: new empty list
Overrides: object.__init__

__setitem__(self, key, value)
(Index assignment operator)

source code 

x[i]=y

Overrides: list.__setitem__
(inherited documentation)

__delitem__(self, key)
(Index deletion operator)

source code 

del x[y]

Overrides: list.__delitem__
(inherited documentation)

normalize(self, **kwargs)

source code 

Create a new normaliyed ranking out of a messy ranking like [1,3,5,4] to [1,2,4,3]

Parameters:
  • ties - Select how to handle ties. Accepted values are:
    • 'minimize', which reserves only one rank position for all tied items of the same rank
    • 'floor', which reserves all rank positions for all tied items of the same rank, but sets their value to the minimum tied rank position
    • 'ceiling', which reserves all rank positions for all tied items of the same rank, but sets their value to the maximum tied rank position
    • 'middle', which reserves all rank positions for all tied items of the same rank, but sets their value to the middle of the tied rank positions
  • inflate_ties (boolean @return a new normalized ranking @rtype Ranking)

indexes(self, neededrank)

source code 

Returns the indexes of the particular ranks in the list

Parameters:
  • ranking_list (list) - the list of ranks that will be searched
  • rank (float) - a rank value
Returns: [int, ...]
the indexes where the given rank appears

inverse(self, **kwargs)

source code 

Created an inverted ranking, so that the best item becomes worse

Parameters:
  • ties - Select how to handle ties. Accepted values are:
    • 'minimize', which reserves only one rank position for all tied items of the same rank
    • 'floor', which reserves all rank positions for all tied items of the same rank, but sets their value to the minimum tied rank position
    • 'ceiling', which reserves all rank positions for all tied items of the same rank, but sets their value to the maximum tied rank position
    • 'middle', which reserves all rank positions for all tied items of the same rank, but sets their value to the middle of the tied rank positions
Returns: Ranking
the inverted ranking

integers(self)

source code 

Return a version of the ranking, only with integers. It would be nice if the Ranking is normalized

Returns: Ranking
a new ranking with integers