{"id":24474,"library":"pytrec-eval","title":"pytrec_eval","description":"Python bindings for the trec_eval information retrieval evaluation tool, providing standard IR metrics like MAP, NDCG, P@k, etc. Supports Python 3+. Current version 0.5 is the latest stable release. Updates are infrequent.","status":"active","version":"0.5","language":"python","source_language":"en","source_url":"https://github.com/cvangysel/pytrec_eval","tags":["information-retrieval","evaluation","trec_eval","ranking"],"install":[{"cmd":"pip install pytrec-eval","lang":"bash","label":"PyPI"}],"dependencies":[],"imports":[{"wrong":"import pytrec_eval","symbol":"pytrec_eval","correct":"import pytrec_eval"}],"quickstart":{"code":"import pytrec_eval\n\nqrel = {\n    'q1': {\n        'd1': 1,\n        'd2': 0,\n    }\n}\n\nrun = {\n    'q1': {\n        'd1': 0.9,\n        'd2': 0.1,\n    }\n}\n\nevaluator = pytrec_eval.RelevanceEvaluator(qrel, {'map', 'ndcg'})\nresults = evaluator.evaluate(run)\nprint(results)","lang":"python","description":"Evaluate a run against qrels using MAP and NDCG."},"warnings":[{"fix":"Install trec_eval via system package manager or build from source, and ensure trec_eval is in PATH.","message":"trec_eval binary must be installed separately and on PATH. pytrec_eval does not ship the binary.","severity":"gotcha","affected_versions":"all"},{"fix":"Use str(query_id) and str(doc_id) when building qrel and run dictionaries.","message":"Input dictionaries must have string keys for query and document IDs. Integer keys may cause type errors.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade to Python 3.","message":"Version 0.5 dropped Python 2 support. Older code using Python 2 will break.","severity":"breaking","affected_versions":">=0.5"}],"env_vars":null,"search_vec":"'0.5':28 '3':25 'bind':4 'current':26 'etc':22 'eval':2,8,42 'evalu':11,40 'inform':9,38 'information-retriev':37 'infrequ':36 'ir':15 'k':21 'latest':31 'like':17 'map':18 'metric':16 'ndcg':19 'p':20 'provid':13 'python':3,24 'pytrec':1 'rank':43 'releas':33 'retriev':10,39 'stabl':32 'standard':14 'support':23 'tool':12 'trec':7,41 'updat':34 'version':27","created_at":"2026-05-01T08:13:16.714952+00:00","updated_at":"2026-05-01T08:13:16.714952+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\n  File \"/tmp/tmp4gs8blmy/venv/lib/python3.12/site-packages/pytrec_eval/__init__.py\", line 5, in <module>\n    import numpy as np\nModuleNotFoundError: No module named 'numpy'"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.5","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/cvangysel/pytrec_eval","docs":null,"changelog":null,"pypi":"https://pypi.org/project/pytrec-eval/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}