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.0.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.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: trecrun-0.4.0.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.0.tar.gz
Algorithm Hash digest
SHA256 efc1721b8173d68b6c465487e38ee02db8686b19283ea125f992c3e910e5bdc6
MD5 98dc992984ec19577b4bd97e48ed95e5
BLAKE2b-256 1997323cb497a428c550d4d246c62491fcc96f80b89428b993ca893e997babe4

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: trecrun-0.4.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1a293c270a57c55552eb5d9d5dce5831751f04e9b68d6d6c4a19437857407e8c
MD5 c6d8923477ac817828986b3296d6a02d
BLAKE2b-256 351df19bbbfa08909c6e78c008c5ca97b1d99b0ae08b2625cebaa0edb4467af2

See more details on using hashes here.

Provenance

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