All problems
Re-Identification Rank-1 Accuracy
Problem
Compute rank-1 accuracy for person re-identification.
Each row of preds is a ranked candidate list and gts[i] is the true identity of query i. Count queries whose top candidate matches the ground truth and return the fraction rounded to 4 decimal places. An empty input returns 0.0.
Hint
Only the first entry of each ranked list matters for rank-1.
Test cases
case 1
in: [[[1,2],[3,4]],[1,3]]
expected: 1
case 2
in: [[[2,1],[3,4]],[1,4]]
expected: 0
case 3
in: [[[1],[2],[3]],[1,2,3]]
expected: 1
case 4
in: [[[1,2],[2,1],[3,4]],[2,1,3]]
expected: 0.3333
Starter codePython
def rank1_accuracy(preds, gts):
# Your code here
pass4 test cases · run your code against them in the editor