Skip to main content

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", ...}

Metadata

Release files for pyndeval 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyndeval 0.0.7
File Size Uploaded
pyndeval-0.0.7.tar.gz 15.1 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for pyndeval 0.0.7
File
pyndeval-0.0.7-cp315-cp315-win_amd64.whl CPython 3.15 CPython 3.15 Windows x86-64 Details
pyndeval-0.0.7-cp315-cp315-macosx_10_15_universal2.whl CPython 3.15 CPython 3.15 macOS 10.15+ universal2 (ARM64, x86-64) Details
pyndeval-0.0.7-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
pyndeval-0.0.7-cp314-cp314-macosx_10_15_universal2.whl CPython 3.14 CPython 3.14 macOS 10.15+ universal2 (ARM64, x86-64) Details
pyndeval-0.0.7-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
pyndeval-0.0.7-cp313-cp313-macosx_10_13_universal2.whl CPython 3.13 CPython 3.13 macOS 10.13+ universal2 (ARM64, x86-64) Details
pyndeval-0.0.7-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
pyndeval-0.0.7-cp312-cp312-macosx_10_13_universal2.whl CPython 3.12 CPython 3.12 macOS 10.13+ universal2 (ARM64, x86-64) Details
pyndeval-0.0.7-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
pyndeval-0.0.7-cp311-cp311-macosx_10_9_universal2.whl CPython 3.11 CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64) Details
pyndeval-0.0.7-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
pyndeval-0.0.7-cp310-cp310-macosx_10_9_universal2.whl CPython 3.10 CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64) Details
pyndeval-0.0.7-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
pyndeval-0.0.7-cp39-cp39-macosx_10_9_universal2.whl CPython 3.9 CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64) Details
pyndeval-0.0.7-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
pyndeval-0.0.7-cp38-cp38-macosx_11_0_universal2.whl CPython 3.8 CPython 3.8 macOS 11.0+ universal2 (ARM64, x86-64) Details

Total release size: 514.2 kB

Release files / pyndeval-0.0.7.tar.gz

Download URL pyndeval-0.0.7.tar.gz
Size 15.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8809cdfe434d65d0a9dc44836d203351a66a5d39e682ee7163d1d2cdf50bc1c3
BLAKE2b-256 checksum
How to use checksums
c1143e36218f2952a92429f79bac3bc82cb1e0fcc36d9f69d588c696b8c312c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / pyndeval-0.0.7-cp315-cp315-win_amd64.whl

Download URL pyndeval-0.0.7-cp315-cp315-win_amd64.whl
Size 18.1 kB
Tags CPython 3.15 Windows x86-64
SHA-256 checksum
How to use checksums
63800a514f6c7f95e3255262a312a802fef8e865429dfa3f2411c3bcfdcf85ba
BLAKE2b-256 checksum
How to use checksums
2eb44e723b8d08f16d3e7f5b95f6e2defb5e498c7c39027ea795198036da0bd5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0

Release files / pyndeval-0.0.7-cp315-cp315-macosx_10_15_universal2.whl

Download URL pyndeval-0.0.7-cp315-cp315-macosx_10_15_universal2.whl
Size 45.0 kB
Tags CPython 3.15 macOS 10.15+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
fb165f116c85ee7548e8f8808438be26f3d8af9cf6e679332374ffa9b5e2801e
BLAKE2b-256 checksum
How to use checksums
ea8d11f2c361d9a708a285208cda5f4bcbadbb12dd8ea3400b8ae89c090e2c64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0

Release files / pyndeval-0.0.7-cp314-cp314-win_amd64.whl

Download URL pyndeval-0.0.7-cp314-cp314-win_amd64.whl
Size 18.1 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
db43b2831bccd21698032751d60091a217fbe1880fb20194337186a14d2122f7
BLAKE2b-256 checksum
How to use checksums
b8032ecd9f28921f61c899d36ad947708c3366cd4283d60e82b6f9d6337cd5a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / pyndeval-0.0.7-cp314-cp314-macosx_10_15_universal2.whl

Download URL pyndeval-0.0.7-cp314-cp314-macosx_10_15_universal2.whl
Size 45.0 kB
Tags CPython 3.14 macOS 10.15+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
b619f76a7e8a0bf7ab052c7e2ea7a95b89e2f14a3400e4219a73c2bcf5522ac2
BLAKE2b-256 checksum
How to use checksums
95c57ab23f1162565ddbec0493a6b99fe42139abe4a002ce6be65c7190edef6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / pyndeval-0.0.7-cp313-cp313-win_amd64.whl

Download URL pyndeval-0.0.7-cp313-cp313-win_amd64.whl
Size 17.3 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
1214c773fc8caf21c6619343bf56a7441d9ae2d203b8bf472404f7ebd1c92d0b
BLAKE2b-256 checksum
How to use checksums
4bf4183c11557fe4d711ac9cd21550ac29a1588bc3481032baf388e82c40636b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pyndeval-0.0.7-cp313-cp313-macosx_10_13_universal2.whl

Download URL pyndeval-0.0.7-cp313-cp313-macosx_10_13_universal2.whl
Size 44.9 kB
Tags CPython 3.13 macOS 10.13+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
086d3a02927f70f7960c45c6175d1ff0ff5f872c8165c37640af7f065477b29c
BLAKE2b-256 checksum
How to use checksums
e47c691d2e268ac393e968ad3528897c8fb9f12cebc7b4f241927251720d344d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / pyndeval-0.0.7-cp312-cp312-win_amd64.whl

Download URL pyndeval-0.0.7-cp312-cp312-win_amd64.whl
Size 17.3 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
23c25f34b1f17861ccb152a79e6df8a3d3abf92a23651acd89e8d24e2f510736
BLAKE2b-256 checksum
How to use checksums
2e6cd26d6120de94228b36254f955fa223282547ff3913e2113f5de226f028df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / pyndeval-0.0.7-cp312-cp312-macosx_10_13_universal2.whl

Download URL pyndeval-0.0.7-cp312-cp312-macosx_10_13_universal2.whl
Size 44.9 kB
Tags CPython 3.12 macOS 10.13+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
9733882419fb5e060e046500578485b4855c2b2321b24543b0f48677da6f2cd4
BLAKE2b-256 checksum
How to use checksums
def6c0266c7308cb685f05d5ace2861fafa39400035babcc11d0bb8b4814e89b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / pyndeval-0.0.7-cp311-cp311-win_amd64.whl

Download URL pyndeval-0.0.7-cp311-cp311-win_amd64.whl
Size 17.3 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
3892d23835ba59e97edf06a732a69dce5c539ba93eeb214f1e573d811a87e5fe
BLAKE2b-256 checksum
How to use checksums
b5f812d03fdcce2105fd0a9d11d1a2e2c859d492db13b1d14f97022b4d7feb97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / pyndeval-0.0.7-cp311-cp311-macosx_10_9_universal2.whl

Download URL pyndeval-0.0.7-cp311-cp311-macosx_10_9_universal2.whl
Size 44.8 kB
Tags CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
6919285bac0efd7a15d3116669ebc51984aa3ec00793928a202848d37dbc112a
BLAKE2b-256 checksum
How to use checksums
264e4a69558b10ea27680f7a71a572f3d0ab91eb80664ba5931dea7fe1d0e773
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / pyndeval-0.0.7-cp310-cp310-win_amd64.whl

Download URL pyndeval-0.0.7-cp310-cp310-win_amd64.whl
Size 17.3 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
697fa9d53da8aaa714e1df3ef6e4625b0c9e78dcca0a6e9fef6f71f7428cb0cb
BLAKE2b-256 checksum
How to use checksums
c269b53c39f3072e3aba9e5da70148f38207cc980b9d52e72a81491fbb3b2242
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Release files / pyndeval-0.0.7-cp310-cp310-macosx_10_9_universal2.whl

Download URL pyndeval-0.0.7-cp310-cp310-macosx_10_9_universal2.whl
Size 44.8 kB
Tags CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
4980a71038b6d3881eed80f175f695d72b1ccf14d8a23825018b9f1e307f900e
BLAKE2b-256 checksum
How to use checksums
e05e87e19e724e9a14ffbcf1ce9d55b9ae25ad30a52fd154cbc2242319298de1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Release files / pyndeval-0.0.7-cp39-cp39-win_amd64.whl

Download URL pyndeval-0.0.7-cp39-cp39-win_amd64.whl
Size 17.3 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
de73a0886b38f2e046750f9f5fcaa102b9c2a515a994f68196b539ec972bfd12
BLAKE2b-256 checksum
How to use checksums
fb3bfbf2946e23f5ed717608f79a9475fdfd481c1447080791438799fe2ceee5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.13

Release files / pyndeval-0.0.7-cp39-cp39-macosx_10_9_universal2.whl

Download URL pyndeval-0.0.7-cp39-cp39-macosx_10_9_universal2.whl
Size 44.8 kB
Tags CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
c67ff228cfec0a016ca97f278492880449ddffc85fc3888c3d9f03a546dad9d9
BLAKE2b-256 checksum
How to use checksums
4c528c11db5f5d7c2c3a82970329c3f8bfaa1722144ffdb95ea6b9f769c21454
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.13

Release files / pyndeval-0.0.7-cp38-cp38-win_amd64.whl

Download URL pyndeval-0.0.7-cp38-cp38-win_amd64.whl
Size 17.3 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
675773476d86cbf182f30d095707fa85fc533d9af002ced922717964275e7977
BLAKE2b-256 checksum
How to use checksums
dc9f44d126d195e7c3003f459efe635d62710679d6cf2b3c415214ce607487d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.10

Release files / pyndeval-0.0.7-cp38-cp38-macosx_11_0_universal2.whl

Download URL pyndeval-0.0.7-cp38-cp38-macosx_11_0_universal2.whl
Size 44.8 kB
Tags CPython 3.8 macOS 11.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
02a88bca0389475e9305c3e79457f581ca268085fb1b22b38674ef3183f010a5
BLAKE2b-256 checksum
How to use checksums
b8ed31fedba2d66079c259a8aa57d9dac11c773f98098a1808c200ab6bc0e706
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.10

Release history Release notifications | RSS feed

0.0.8

26 release files

This release

0.0.7 This release

17 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page