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.4.tar.gz (12.6 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.4-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: trecrun-0.4.4.tar.gz
  • Upload date:
  • Size: 12.6 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.4.tar.gz
Algorithm Hash digest
SHA256 b3235ef5610cb91ce88a02ccc24ea07ce6c365367a9705e3a2dc8b5b76f06d51
MD5 01d609c3dc4a3c8816fe98464b127fd5
BLAKE2b-256 4e9a8465d3543c88a6f4c0473eea6898309b2cf9013b613c97dd775b2300eee1

See more details on using hashes here.

Provenance

The following attestation bundles were made for trecrun-0.4.4.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.4-py3-none-any.whl.

File metadata

  • Download URL: trecrun-0.4.4-py3-none-any.whl
  • Upload date:
  • Size: 9.6 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 267ec6d03825b39f87d784cf85fcc08e26489563beb3b63127ec79cecaa67e89
MD5 3cc69f6f57198ba026f8d6b2d3735260
BLAKE2b-256 50c448174fe566cd4ac2b0a31a895821ea399b07fb8d3baf0b8d338c88d2e51a

See more details on using hashes here.

Provenance

The following attestation bundles were made for trecrun-0.4.4-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