Skip to content

Is it possible to calculate metric for groups seperately? #1654

Answered by Wicknight
bhuebner3 asked this question in General
Discussion options

You must be logged in to vote

Hello @bhuebner3 , I think this is feasible, and here is my solution :

  1. Locate the NDCG class in RecBole/recbole/evaluator/metrics.py.
  2. Then you can find the metric_info function in this file, just as follows:
    def metric_info(self, pos_index, pos_len):
        len_rank = np.full_like(pos_len, pos_index.shape[1])
        idcg_len = np.where(pos_len > len_rank, len_rank, pos_len)

        iranks = np.zeros_like(pos_index, dtype=np.float)
        iranks[:, :] = np.arange(1, pos_index.shape[1] + 1)
        idcg = np.cumsum(1.0 / np.log2(iranks + 1), axis=1)
        for row, idx in enumerate(idcg_len):
            idcg[row, idx:] = idcg[row, idx - 1]

        ranks = np.zeros_like(pos_inde…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@bhuebner3
Comment options

@TangJiakai
Comment options

Answer selected by bhuebner3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants