All problems
Anchor Precision
Problem
Compute anchor precision: among instances covered by the anchor, the fraction whose prediction matches the anchor's.
Return 0.0 when nothing is covered or input is empty.
Hint
An anchor is only useful if the prediction rarely changes inside it.
Test cases
case 1
in: [[1,1,0,1],[1,0,0,1]]
expected: 0.6666666666666666
case 2
in: [[0,0],[1,1]]
expected: 0
case 3
in: [[],[]]
expected: 0
Starter codePython
def anchor_precision(covered, same_prediction):
# Your code here
pass3 test cases · run your code against them in the editor