Calculates and returns metrics.
(references,
predictions,
is_regex)
| 73 | |
| 74 | |
| 75 | def evaluate_predictions_impl(references, |
| 76 | predictions, |
| 77 | is_regex): |
| 78 | """Calculates and returns metrics.""" |
| 79 | missing_predictions = 0 |
| 80 | correct = 0 |
| 81 | for question, answer in references.items(): |
| 82 | if question in predictions: |
| 83 | # pdb.set_trace() |
| 84 | correct += int( |
| 85 | is_correct(answers=answer, prediction=predictions[question], is_regex=is_regex)) |
| 86 | else: |
| 87 | missing_predictions += 1 |
| 88 | |
| 89 | return dict( # pytype: disable=bad-return-type # dict-kwargs |
| 90 | missing_predictions=missing_predictions, |
| 91 | num_correct=correct, |
| 92 | num_total=len(references), |
| 93 | accuracy=correct / float(len(references))) |
| 94 | |
| 95 | |
| 96 | def find_last_uppercase_abcd(s): |
no test coverage detected