pytrec-eval
Provides Python bindings for popular Information Retrieval measures implemented within trec_eval.
Decision gist · record as of 2026-08-14
Yes, if you need standard IR evaluation metrics in Python and can meet the C++ build requirements. The package is dormant but stable, carries no known vulnerabilities, and wraps a trusted reference implementation. Install only if you're comfortable with a package that hasn't been updated since 2020 and verify compatibility with your Python version before relying on it in production.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires a C++ compiler and Python development headers; developed for Python 3.5 and requires Python >= 3.
- Installation requires a C++ compiler and Python development headers; the package is dormant (last release 2020-09-07, last commit 2023-10-10) but carries no known vulnerabilities and has accumulated 350 repository stars.
License · maintenance · safety
permissive license (permissive) — Licensed under the MIT license (permissive), allowing commercial and private use; note that the underlying trec_eval tool is licensed separately.
last release 2020-09-07 (2167 days) · last repo commit 2023-10-10 · 350 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 96,187 downloads/mo, #13,224 on PyPI
Alternatives
Verify before relying
pip install pytrec_eval
import pytrec_eval
qrel = {'q1': {'d1': 0, 'd2': 1}}
run = {'q1': {'d1': 1.0, 'd2': 0.0}}
evaluator = pytrec_eval.RelevanceEvaluator(qrel, {'map', 'ndcg'})
results = evaluator.evaluate(run)- Whether numpy and scipy are runtime dependencies or only build-time requirements (description lists them but fact sheet shows n_runtime: 0).
- Current compatibility with modern Python versions beyond the 3.5 development baseline.
- Whether the package is actively maintained or if dormancy signals end-of-life.
What it is and what it does
pytrec_eval is a Python wrapper around TREC's trec_eval tool, a standard reference implementation for computing Information Retrieval evaluation metrics. It lets you compute measures like MAP (Mean Average Precision) and NDCG (Normalized Discounted Cumulative Gain) by passing relevance judgments and ranked results as Python dictionaries, then get back computed scores for each query.
The package is designed to eliminate the need for custom metric implementations in Python research code. It wraps the compiled trec_eval engine via C++ bindings, so it inherits the correctness and performance of the reference implementation. Installation requires a C++ compiler and Python development headers; the package has been dormant since 2020 but carries no known security issues.
Use it for
- Evaluate information retrieval systems in Python research pipelines without reimplementing standard metrics.
- Compute ranking quality metrics (MAP, NDCG, etc.) for search or recommendation system experiments.
- Perform statistical significance testing between two ranked result sets using standard IR measures.
- Validate IR models by scoring ranked results against ground-truth relevance judgments in batch.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need standard IR evaluation metrics in Python and can meet the C++ build requirements.
The package is dormant but stable, carries no known vulnerabilities, and wraps a trusted reference implementation. Install only if you're comfortable with a package that hasn't been updated since 2020 and verify compatibility with your Python version before relying on it in production.
Install
pytrec-eval on PyPI
Before you install
Installation requires a C++ compiler and Python development headers; the package is dormant (last release 2020-09-07, last commit 2023-10-10) but carries no known vulnerabilities and has accumulated 350 repository stars.
Requires a C++ compiler and Python development headers; developed for Python 3.5 and requires Python >= 3.
License in practice
Licensed under the MIT license (permissive), allowing commercial and private use; note that the underlying trec_eval tool is licensed separately.
Quickstart
pip install pytrec_eval
import pytrec_eval
qrel = {'q1': {'d1': 0, 'd2': 1}}
run = {'q1': {'d1': 1.0, 'd2': 0.0}}
evaluator = pytrec_eval.RelevanceEvaluator(qrel, {'map', 'ndcg'})
results = evaluator.evaluate(run)
Verify before relying
- Whether numpy and scipy are runtime dependencies or only build-time requirements (description lists them but fact sheet shows n_runtime: 0).
- Current compatibility with modern Python versions beyond the 3.5 development baseline.
- Whether the package is actively maintained or if dormancy signals end-of-life.
Package facts
| License | permissive license permissive |
| Python support | Supports the current Python release >=3 |
| Install friction | High. Source build required |
| Runtime dependencies | None |
| Maintenance | Dormant 2,167 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 96,187 / month, #13,224 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 3 - AlphaIntended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseOperating System :: POSIX :: LinuxProgramming Language :: C++Programming Language :: PythonTopic :: Text Processing :: General |
Evidence: pytrec_eval-0.5.tar.gz
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “ndcg map calculation”
- pytrec-evalProvides Python bindings to compute standard Information Retrieval…
- ir-measuresProvides a unified Python interface to compute standard information…
- ranxranx computes ranking evaluation metrics (precision, recall, NDCG,…
Give your agent the search over MCP, or paste the wish link into any chat.
More General packages
A drop-in replacement for Python's standard `re` module that adds advanced regex features like nested sets, fuzzy matching, lookaround in conditionals, and full Unicode case-folding while maintaining backward compatibility.
Docutils converts plaintext documentation in reStructuredText format into multiple output formats including HTML, XML, and LaTeX using a modular processing system.
Sphinx generates professional documentation from reStructuredText source files, producing HTML, PDF, EPUB, and other formats with automatic cross-references, code highlighting, and hierarchical navigation.
Lark is a parsing library that builds abstract syntax trees from context-free grammars, supporting multiple parsing algorithms (Earley, LALR(1), CYK) with automatic line and column tracking.
NLTK is a Python library for natural language processing tasks including tokenization, parsing, tagging, and linguistic analysis, with built-in datasets and educational resources.
Install it if you need foundational NLP tools, linguistic datasets, or are learning the field; consider specialized libraries (spaCy, transformers) if you need…
Converts numbers, dates, times, and file sizes into human-readable text formats, with support for fuzzy durations like "3 minutes ago" and localization to multiple languages.
Install it if you need to display human-readable numbers, durations, or sizes to end users.
See also ir-measures · pytrec-eval-terrier · trec-car-tools · ranx · ir-datasets · mir-eval · colbert-ai · py-expression-eval · deepeval · voyageai