All problems
Confusion Pair Rate
Problem
Measure how often one gold label is confused with a specific predicted label. gold and pred are parallel label lists, and gold_label and pred_label name the confusion pair.
Return the fraction of gold_label positions that were predicted as pred_label, or 0.0 when gold_label never occurs.
Hint
The denominator is the count of the gold label, not the total number of tokens.
Test cases
case 1
in: [["A","A","A","B"],["B","A","B","B"],"A","B"]
expected: 0.6666666666666666
case 2
in: [["A","A","A","B"],["B","A","B","B"],"B","B"]
expected: 1
case 3
in: [["A","A","A","B"],["B","A","B","B"],"C","B"]
expected: 0
case 4
in: [[],[],"A","B"]
expected: 0
Starter codePython
def confusion_pair_rate(gold, pred, gold_label, pred_label):
# Your code here
pass4 test cases · run your code against them in the editor