in code/run_eval_prm_trl.py [0:0]
def precision_recall(results: list[dict[str, bool | str | int]]) -> tuple[float] | None:
"""Compute precision and recall over the list of obtained results. """
errors = []
corrects = []
for result in results:
if result["label"] == -1:
corrects.append(result["match"])
else:
errors.append(result["match"])
precision = np.mean(errors) * 100 if len(errors) > 0 else None
recall = np.mean(corrects) * 100 if len(corrects) > 0 else None
return precision, recall