-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect Evaluation Metrics Produced #187
Comments
Recall@10 : 1.00 NDCG@10 : 1.00 Why is precision@10 not 1.00 ? |
|
BEIR use pytrec_eval to evaluate. Maybe the solutions can be found in pytrec_eval issuses. |
y = [[1,2,3,4,5,6,7,8,9,10],
[11,12,13,14,15,16,17,18,19,20],
[21,22,23,24,25,26,27,28,29,30]
]
y_hat = [[8, 1, 4, 9, 7, 3, 5, 6, 10, 2],
[15, 13, 18, 11, 20, 14, 17, 16, 19, 12],
[27, 28, 23, 21, 29, 30, 22, 25, 26, 24]
]
evaluator = Beir_Evaluator(y)
evaluator.evaluate_retrieval(y_hat) Output from beir.retrieval.evaluation import EvaluateRetrieval
class Beir_Evaluator():
def __init__(self,benchmarks):
self.benchmarks = benchmarks
def _get_beir_format(self,results):
return {
str(i): {str(item): int(item) for item in sublist}
for i, sublist in enumerate(results)
}
def evaluate_retrieval(self,retrieved_contexts,k_vals = [10]):
actual_contexts = self._get_beir_format(self.benchmarks)
retrieved_contexts = self._get_beir_format(retrieved_contexts)
ndcg, map_score, recall, precision = EvaluateRetrieval.evaluate(
actual_contexts, retrieved_contexts, k_values=k_vals
)
mrr = EvaluateRetrieval.evaluate_custom(actual_contexts, retrieved_contexts, k_vals, metric="mrr")
# Print evaluation results
for k in k_vals:
print(f"\n{k}:")
print(f"Recall@{k} : {recall[f'Recall@{k}']:.2f}")
print(f"Precision@{k}: {precision[f'P@{k}']:.2f}")
print(f"NDCG@{k} : {ndcg[f'NDCG@{k}']:.2f}")
print(f"MAP@{k} : {map_score[f'MAP@{k}']:.2f}")
print(f"MRR@{k} : {mrr[f'MRR@{k}']:.2f}") Would this be a good approach and is there any benefit in creating a PR ? |
`def beir_evaluation():
Recall@10 : 0.90
Precision@10: 0.90
NDCG@10 : 0.94
MAP@10 : 0.90
MRR@10 : 1.00
This is clearly incorrect as everything should be 1. Please can this be resolved
The text was updated successfully, but these errors were encountered: