Skip to main content

Interface to ndeval.c

Project description

pyndeval

A python interface to TREC's ndeval.c, used for computing diversity retrieval metrics.

Getting Started

From pip:

pip install pyndeval

Or install from source:

git clone https://github.com/seanmacavaney/pyndeval.git
cd pyndeval
python setup.py install

Usage

import pyndeval
from pyndeval import SubtopicQrel, ScoredDoc

# provide qrels as a list of tuples
qrels = [
    SubtopicQrel("0", "a", "A", 1),
    SubtopicQrel("0", "b", "B", 1),
    SubtopicQrel("0", "b", "D", 1),
    SubtopicQrel("0", "c", "C", 1),
]

# provide run as a list of tuples
run = [
    ScoredDoc("0", "A", 9.3),
    ScoredDoc("0", "D", 8.4),
    ScoredDoc("0", "E", 8.1), # not in qrels
    ScoredDoc("0", "B", 7.6),
    # C not retrieved
]

pyndeval.ndeval(qrels, run)
{'0': {
  'ERR-IA@5': 0.3933,
  'ERR-IA@10': 0.3907,
  'ERR-IA@20': 0.3907,
  'nERR-IA@5': 0.8297,
  'nERR-IA@10': 0.8297,
  'nERR-IA@20': 0.8297,
  'alpha-DCG@5': 0.4052,
  'alpha-DCG@10': 0.3998,
  'alpha-DCG@20': 0.3997,
  'alpha-nDCG@5': 0.7868,
  'alpha-nDCG@10': 0.7868,
  'alpha-nDCG@20': 0.7868,
  'NRBP': 0.3906,
  'nNRBP': 0.8620,
  'MAP-IA': 0.5000,
  'P-IA@5': 0.2000,
  'P-IA@10': 0.1000,
  'P-IA@20': 0.0500,
  'strec@5': 0.6666,
  'strec@10': 0.6666,
  'strec@20': 0.6666
}}

Supported measures

pyndeval supports the following measures:

  • ERR-IA@k
  • nERR-IA@k
  • alpha-DCG@k
  • alpha-nDCG@k
  • P-IA@k
  • strec@k
  • NRBP
  • nNRBP
  • MAP-IA

Measures with @k support values from 1-20 (upper limit from ndeval.c).

Measures are provided as a list of strings with the measures= parameter.

pyndeval.ndeval(qrels, run, measures=["ERR-IA@7", "MAP-IA"])

Reusing qrels

If you're running multiple times for the same set of qrels and measures, you can speed it up by building a RelevanceEvaluator object, which caches the internal qrel representations.

ev = pyndeval.RelevanceEvaluator(qrels)
ev.evaluate(run1)
ev.evaluate(run2)
ev.evaluate(run3)
ev.evaluate(run4)

Iterable results

for result in pyndeval.ndeval_iter(qrels, run):
  {"query_id": "0", ...}
for result in ev.evaluate_iter(run):
  {"query_id": "0", ...}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyndeval-0.0.4.tar.gz (15.0 kB view hashes)

Uploaded Source

Built Distributions

pyndeval-0.0.4-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (21.5 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pyndeval-0.0.4-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (23.2 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyndeval-0.0.4-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (21.5 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pyndeval-0.0.4-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (23.2 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyndeval-0.0.4-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (21.6 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pyndeval-0.0.4-pp37-pypy37_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (23.2 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyndeval-0.0.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (56.3 kB view hashes)

Uploaded CPython 3.13 manylinux: glibc 2.17+ x86-64

pyndeval-0.0.4-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (57.3 kB view hashes)

Uploaded CPython 3.13 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyndeval-0.0.4-cp312-cp312-win_amd64.whl (17.9 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

pyndeval-0.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (56.3 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pyndeval-0.0.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (57.3 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyndeval-0.0.4-cp311-cp311-win_amd64.whl (17.9 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

pyndeval-0.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (56.1 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pyndeval-0.0.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (57.2 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyndeval-0.0.4-cp310-cp310-win_amd64.whl (17.9 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

pyndeval-0.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (55.9 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pyndeval-0.0.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (57.0 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyndeval-0.0.4-cp39-cp39-win_amd64.whl (17.9 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

pyndeval-0.0.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (55.7 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pyndeval-0.0.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (56.8 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyndeval-0.0.4-cp38-cp38-win_amd64.whl (17.9 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

pyndeval-0.0.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (55.5 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pyndeval-0.0.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (56.6 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyndeval-0.0.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (55.1 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

pyndeval-0.0.4-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (56.2 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyndeval-0.0.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (55.1 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

pyndeval-0.0.4-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (56.2 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page