Skip to content
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

Metrics missing when running evaluator twice #22

Open
dfdazac opened this issue May 12, 2020 · 0 comments
Open

Metrics missing when running evaluator twice #22

dfdazac opened this issue May 12, 2020 · 0 comments

Comments

@dfdazac
Copy link

dfdazac commented May 12, 2020

Kudos for the great interface!

I have been running some evaluations where I obtain the NDCG@10 and NDCG@100 metrics. I noticed that if I run the evaluator twice, the second time only one of the metrics appears. Here is a simple example, modified from simple.py:

import pytrec_eval
import json

qrel = {
    'q1': {
        'd1': 0,
        'd2': 1,
        'd3': 0,
    },
    'q2': {
        'd2': 1,
        'd3': 1,
    },
}

run = {
    'q1': {
        'd1': 1.0,
        'd2': 0.0,
        'd3': 1.5,
    },
    'q2': {
        'd1': 1.5,
        'd2': 0.2,
        'd3': 0.5,
    }
}

evaluator = pytrec_eval.RelevanceEvaluator(
    qrel, {'ndcg_cut_10', 'ndcg_cut_100'})

print(json.dumps(evaluator.evaluate(run), indent=1))
# Just calling .evaluate() again, but run could be different
print(json.dumps(evaluator.evaluate(run), indent=1))

Output:

{
 "q1": {
  "ndcg_cut_10": 0.5,
  "ndcg_cut_100": 0.5
 },
 "q2": {
  "ndcg_cut_10": 0.6934264036172708,
  "ndcg_cut_100": 0.6934264036172708
 }
}
{
 "q1": {
  "ndcg_cut_10": 0.5
 },
 "q2": {
  "ndcg_cut_10": 0.6934264036172708
 }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant