inFairness.utils.ndcg module#

inFairness.utils.ndcg.discounted_cumulative_gain(relevances)[source]#
inFairness.utils.ndcg.monte_carlo_vect_ndcg(relevances)#

Takes a vector of relevances and computes the normalized discounted cumulative gain Refer (Wikipedia - Discounted Cumulative Gain)[https://en.wikipedia.org/wiki/Discounted_cumulative_gain] for more information.

Parameters:

relevances (torch.Tensor) – vector of dimension N where each element is the relevance of some objects in a particular order

Returns:

normalized_discounted_cumulative_gain – scalar value corresponding to the normalized discounted cumulative gain

Return type:

torch.Tensor

inFairness.utils.ndcg.normalized_discounted_cumulative_gain(relevances)[source]#

Takes a vector of relevances and computes the normalized discounted cumulative gain Refer (Wikipedia - Discounted Cumulative Gain)[https://en.wikipedia.org/wiki/Discounted_cumulative_gain] for more information.

Parameters:

relevances (torch.Tensor) – vector of dimension N where each element is the relevance of some objects in a particular order

Returns:

normalized_discounted_cumulative_gain – scalar value corresponding to the normalized discounted cumulative gain

Return type:

torch.Tensor

inFairness.utils.ndcg.vect_normalized_discounted_cumulative_gain(relevances)#

Adds a further outer dimension to the vectorized normalized discounted cumulative gain so it works on monte carlo samples of rankings (e.g. samples of a plackett-luce distribution).

This function would take a tensor of size S,B,N and return a tensor of size S,B with the ndcg of each vector.