In methods precision(link), the indices returned by _setup_metric is the indices of top k labels, with scores sorted ascendingly. But when calculating precision@k, we want to use cumsum when scores in eval_flags are sorted descendingly. The same is to psprecision since it uses precision as a subroutine.
I just add change indices to indices[:, ::-1] in _get_top_k. Guess it is just a workaround.
In methods
precision
(link), theindices
returned by_setup_metric
is the indices of top k labels, with scores sorted ascendingly. But when calculating precision@k, we want to use cumsum when scores ineval_flags
are sorted descendingly. The same is topsprecision
since it usesprecision
as a subroutine.I just add change
indices
toindices[:, ::-1]
in _get_top_k. Guess it is just a workaround.