def test_array_match_wrong(): stat = gold.RightWrongCount() stat.compare_lists = True gold_ans = {'hello': [1, 9, 3]} taskrun = {'hello': [1, 2, 3]} stat = gold.compute(stat, taskrun, gold_ans, 'hello') stat.right == 0 stat.wrong == 1
def test_confusion_matrix_list_2(): stat = gold.ConfusionMatrix(['True', 'False']) gold_ans = {'hello': ['True', 'False', 'False', 'False']} taskrun = {'hello': ['True', 'True', 'False', 'True']} stat = gold.compute(stat, taskrun, gold_ans, 'hello') assert stat.value['matrix'][0][0] == 1, stat.value['matrix'] assert stat.value['matrix'][0][1] == 0, stat.value['matrix'] assert stat.value['matrix'][1][0] == 2, stat.value['matrix'] assert stat.value['matrix'][1][1] == 1, stat.value['matrix']
def test_many_labels(): stat = gold.ConfusionMatrix(['A', 'B', 'C', 'D']) true = ['A', 'A', 'B', 'B', 'C', 'C', 'D', 'D'] obs = ['B', 'C', 'B', 'B', 'D', 'C', 'A', 'B'] gold_ans = {'hello': [{'world': value} for value in true]} taskrun = {'hello': [{'world': value} for value in obs]} stat = gold.compute(stat, taskrun, gold_ans, 'hello.world') assert stat.value['matrix'][0][1] == 1, stat.value['matrix'] assert stat.value['matrix'][0][2] == 1, stat.value['matrix'] assert stat.value['matrix'][1][1] == 2, stat.value['matrix'] assert stat.value['matrix'][2][2] == 1, stat.value['matrix'] assert stat.value['matrix'][2][3] == 1, stat.value['matrix'] assert stat.value['matrix'][3][0] == 1, stat.value['matrix'] assert stat.value['matrix'][3][1] == 1, stat.value['matrix'] assert (np.array(stat.value['matrix']) >= 0).all(), stat.value['matrix'] assert np.array(stat.value['matrix']).sum() == len(true)
def test_confusion_matrix_invalueid_answer(): stat = gold.ConfusionMatrix(['True', 'False']) gold_ans = {'hello': 'True'} taskrun = {'hello': 'None'} stat = gold.compute(stat, taskrun, gold_ans, 'hello') stat.value['matrix'] == [[0, 0], [0, 0]]