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

Module ranking

source code

Utility functions and classes for ranking. Can be used both in a pythonic or an object-oriented way wrapped in Ranking class

Created on 20 Mar 2013


Author: Eleftherios Avramidis

Classes [hide private]
  Ranking
Class that wraps the functionality of a ranking list.
Functions [hide private]
[int, ...]
indexes(ranking_list, neededrank)
Returns the indexes of the particular ranks in the list
source code
tuple(float, float)
_handle_tie(ranking_list, original_rank, modified_rank, ties_handling)
Modifies the values of the tied items as specified by the parameters
source code
[float, ...]
normalize(ranking_list, **kwargs)
Convert a messy ranking like [1,3,5,4] to [1,2,4,3]
source code
[float, ...]
invert(ranking_list, **kwargs)
Inverts a ranking list so that the best item becomes worse and vice versa
source code
Variables [hide private]
  __package__ = None
hash(x)
Function Details [hide private]

indexes(ranking_list, 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

_handle_tie(ranking_list, original_rank, modified_rank, ties_handling)

source code 

Modifies the values of the tied items as specified by the parameters

Parameters:
  • ranking_list (list) - the list of ranks
  • original_rank (float) - the original rank value
  • modified_rank (float) - the new normalized rank value that would have been assigned if there was no tie
  • ties_handling - A string defining the mode of handling ties. For the description see function normalized()
Returns: tuple(float, float)
the new value of the given rank after considering its ties and the value of the rank that the normalization iteration should continue with

normalize(ranking_list, **kwargs)

source code 

Convert a messy ranking like [1,3,5,4] to [1,2,4,3]

Parameters:
  • ranking_list (list) - the list of ranks that will be normalized
  • 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 (string)
Returns: [float, ...]
a new normalized list of ranks

invert(ranking_list, **kwargs)

source code 

Inverts a ranking list so that the best item becomes worse and vice versa

Parameters:
  • ranking_list ([float, ...]) - the list whose ranks are to be inverted
Returns: [float, ...]
the inverted rank list