From 3111befe085e2d4c83aefe103159da8e6de341fa Mon Sep 17 00:00:00 2001 From: Unai Garay Maestre Date: Thu, 5 Jan 2023 13:04:30 +0100 Subject: [PATCH] Use invoked logger and not logging library I'm currently using BEIR for evaluating IR systems and the big logging is messing up my terminal. This change brings the use of the invoked logger in line 10 instead of using directly the library logging. This way we can control how and when we log things in the terminal. --- beir/retrieval/evaluation.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/beir/retrieval/evaluation.py b/beir/retrieval/evaluation.py index fd40d72..dda98ef 100644 --- a/beir/retrieval/evaluation.py +++ b/beir/retrieval/evaluation.py @@ -47,7 +47,7 @@ def evaluate(qrels: Dict[str, Dict[str, int]], ignore_identical_ids: bool=True) -> Tuple[Dict[str, float], Dict[str, float], Dict[str, float], Dict[str, float]]: if ignore_identical_ids: - logging.info('For evaluation, we ignore identical query and document ids (default), please explicitly set ``ignore_identical_ids=False`` to ignore this.') + logger.info('For evaluation, we ignore identical query and document ids (default), please explicitly set ``ignore_identical_ids=False`` to ignore this.') popped = [] for qid, rels in results.items(): for pid in list(rels): @@ -87,9 +87,9 @@ def evaluate(qrels: Dict[str, Dict[str, int]], precision[f"P@{k}"] = round(precision[f"P@{k}"]/len(scores), 5) for eval in [ndcg, _map, recall, precision]: - logging.info("\n") + logger.info("\n") for k in eval.keys(): - logging.info("{}: {:.4f}".format(k, eval[k])) + logger.info("{}: {:.4f}".format(k, eval[k])) return ndcg, _map, recall, precision @@ -108,4 +108,4 @@ def evaluate_custom(qrels: Dict[str, Dict[str, int]], return hole(qrels, results, k_values) elif metric.lower() in ["acc", "top_k_acc", "accuracy", "accuracy@k", "top_k_accuracy"]: - return top_k_accuracy(qrels, results, k_values) \ No newline at end of file + return top_k_accuracy(qrels, results, k_values)