Skip to main content

Library for working with TREC run files

Project description

License Worfklow PyPI version fury.io Code style: black

TRECRun

TRECRun is a library for working with TREC run files, with an API heavily inspired by PyTerrier's pipeline operators.

API Operator Description
TRECRun(results) Create a TRECRun object from a dictionary of results or a path to a run file in TREC format.
add(self, other), subtract, multiply, divide +, -, *, / Perform the given operation between self's document scores and other, which can be a TRECRun or a scalar.
topk(self, k) % Retain only the top-k documents for each qid after sorting by score.
intersect(self, other) & Retain only the queries and documents that appear in both self and other.
concat(self, other) Concat the documents in other and self, with those in other appearing at the end. Their scores will be modified to accomplish this.
normalize(self, method='rr') Normalize scores in self using RRF (rr), min-max scaling (minmax), or standardization (standard).
write_trec_run(self, outf) Write self to outfn in TREC format.
evaluate(self, qrels, metrics) Compute metrics for self using qrels and return a dict mapping metric names to their values for each QID. Metrics are computed by ir_measures.

Installation

pip install trecrun

The core library has no required dependencies. Optional features:

  • pip install trecrun[eval] installs ir-measures, which is required by evaluate().
  • pip install trecrun[all] additionally installs smart_open, which enables loading compressed and remote run files.

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

trecrun-0.4.3.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trecrun-0.4.3-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file trecrun-0.4.3.tar.gz.

File metadata

  • Download URL: trecrun-0.4.3.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for trecrun-0.4.3.tar.gz
Algorithm Hash digest
SHA256 9ec598c6a4afa755893d1d9b91b31147b41f5f56270cb41cf1f9ed3b60cf830f
MD5 3ca9b5ee83a595786f15696e4e50c252
BLAKE2b-256 f94a55357ea170ede2ec5bb4a54c1a329742934d80f2457a694cc522836a2f0a

See more details on using hashes here.

Provenance

The following attestation bundles were made for trecrun-0.4.3.tar.gz:

Publisher: publish-release.yml on capreolus-ir/trecrun

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trecrun-0.4.3-py3-none-any.whl.

File metadata

  • Download URL: trecrun-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for trecrun-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 818a5efd5907e758ba0e7340401504a0e30a239411569a4750e94688c7cae7bc
MD5 4ccc112cd25375f53da10f88a94d2fa5
BLAKE2b-256 69d5b2df9f627b11c8747837f661359d8dada63a5c5868ea599b42e855e630da

See more details on using hashes here.

Provenance

The following attestation bundles were made for trecrun-0.4.3-py3-none-any.whl:

Publisher: publish-release.yml on capreolus-ir/trecrun

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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