skcriteria.utils.rank
module¶
Functions for calculate and compare ranks (ordinal series).
- skcriteria.utils.rank.rank_values(arr, reverse=False)[source]¶
Evaluate an array and return a 1 based ranking.
- Parameters
arr ((
numpy.ndarray
,numpy.ndarray
)) – A array with valuesreverse (
bool
default False) – By default (False) the lesser values are ranked first (like in time lapse in a race or Golf scoring) if is True the data is highest values are the first.
- Returns
Array of rankings the i-nth element has the ranking of the i-nth element of the row array.
- Return type
numpy.ndarray
Examples
>>> from skcriteria.util.rank import rank_values >>> # the fastest (the lowest value) goes first >>> time_laps = [0.59, 1.2, 0.3] >>> rank_values(time_laps) array([2, 3, 1]) >>> # highest is better >>> scores = [140, 200, 98] >>> rank_values(scores, reverse=True) array([2, 1, 3])
- skcriteria.utils.rank.dominance(array_a, array_b, reverse=False)[source]¶
Calculate the dominance or general dominance between two arrays.
- Parameters
array_a – The first array to compare.
array_b – The second array to compare.
reverse (bool (default=False)) – array_a[i] ≻ array_b[i] if array_a[i] > array_b[i] if reverse is False, otherwise array_a[i] ≻ array_b[i] if array_a[i] < array_b[i]. Also revese can be an array of boolean of the same shape as array_a and array_b to revert every item independently. In other words, reverse assume the data is a minimization problem.
- Returns
dominance – Named tuple with 4 parameters:
eq: How many values are equals in both arrays.
- aDb: How many values of array_a dominate those of the same
position in array_b.
- bDa: How many values of array_b dominate those of the same
position in array_a.
- eq_where: Where the values of array_a are equals those of the same
position in array_b.
- aDb_where: Where the values of array_a dominates those of the same
position in array_b.
- bDa_where: Where the values of array_b dominates those of the same
position in array_a.
- Return type
_Dominance