scorers

corsort.scorers.scorer_delta(leq)[source]

Scorer delta.

Parameters:

leq (ndarray.) – Matrix of size (n_, n_). Coefficient (i, j) is +1 if we know that item i <= item j, -1 if we know that item i > item j, 0 if we do not know the comparison between them.

Returns:

Score for each item.

Return type:

ndarray

Examples

Up to 1, this is just the sum of the column of the leq matrix:

>>> my_leq = np.array([
...     [ 1,  1,  1,  1],
...     [-1,  1, -1, -1],
...     [-1,  1,  1,  0],
...     [-1,  1,  0,  1],
... ])
>>> scorer_delta(my_leq)
array([-3,  3,  0,  0])

We can deduce the Borda score from it:

>>> n = my_leq.shape[0]
>>> (scorer_delta(my_leq) + n - 1) / 2
array([0. , 3. , 1.5, 1.5])
corsort.scorers.scorer_rho(leq)[source]

Scorer rho.

Parameters:

leq (ndarray.) – Matrix of size (n_, n_). Coefficient (i, j) is +1 if we know that item i <= item j, -1 if we know that item i > item j, 0 if we do not know the comparison between them.

Returns:

Score for each item.

Return type:

ndarray

Examples

>>> my_leq = np.array([
...     [ 1,  1,  1,  1],
...     [-1,  1, -1, -1],
...     [-1,  1,  1,  0],
...     [-1,  1,  0,  1],
... ])
>>> scorer_rho(my_leq)
array([0.25, 4.  , 1.  , 1.  ])