All problems
Majority Vote Accuracy
Problem
For each item, pick the most frequent answer in its sample list (ties broken by the lexicographically smallest label) and compare it with the gold answer. Return the fraction of items where the majority answer is correct. Return 0.0 for an empty sample list, and count empty per-item lists as incorrect.
Test cases
case 1
in: [[["a","a","b"],["b","b","a"]],["a","b"]]
expected: 1
case 2
in: [[[],["a"]],["a","a"]]
expected: 0.5
case 3
in: [[["x","y"]],["z"]]
expected: 0
case 4
in: [[],[]]
expected: 0
Starter codePython
def majority_vote_accuracy(samples, gold):
# Your code here
pass4 test cases · run your code against them in the editor