Skip to main content

Threshold Average Precision: metric for evaluating retrieval rankings

Project description

TAP-k -- Python module for Threshold Average Precision

Threshold Average Precision is a metric for evaluating IR applications that present retrieval lists with a ranking score to the end user. It is described in the following publication:

Hyrum D. Carroll, Maricel G. Kann, Sergey L. Sheetlin, and John L. Spouge: "Threshold Average Precision (TAP-k): A Measure of Retrieval Efficacy Designed for Bioinformatics" (2010). Bioinformatics 26(14):1708-1713. DOI: 10.1093/bioinformatics/btq270

This Python module is based on the authors' reference implementation written in Perl, which can be found at http://www.ncbi.nlm.nih.gov/CBBresearch/Spouge/html.ncbi/tap/.

Installation

Use pip for a system-wide installation:

pip3 install TAP-k

Or simply download the stand-alone script tapk.py.

Requirements

TAP-k runs on Python 3 (Python 3.4 or higher recommended).
No other requirements.

Usage

Installing via pip creates an executable script TAP-k to run from the command line:

TAP-k [options]

If you just downloaded the stand-alone module, use the following call:

python3 tapk.py [options]

Run TAP-k --help to see a short description of all available options.

Example call with minimal output:

$ TAP-k -i test/short.tsv -k 5 -s
EPQ (threshold at 0.5 quantile)	unweighted mean TAP
5 (0.6545522081334377)	0.5664

The input file format is the same as for the original program, which is described here. All output is written to STDOUT. The output format can be changed by specifying format strings (options -f and -Q).

The module can also be used as a library:

>>> import tapk
>>> retlists = ['test/retlists/{}.tsv'.format(fn)
                for fn in ('weighted', 'single')]
>>> result = tapk.tapk(retlists, k=5)
>>> result.tap
0.1311308349769888
>>> result.e0
0.7418847867396157
>>> result.queries
[QueryResult(query='23817572', tap=0.22749287749287747, weight=3.0, T_q=8),
 QueryResult(query='12954810', tap=0.0, weight=1.0, T_q=1),
 QueryResult(query='20729916', tap=0.08055555555555555, weight=2.0, T_q=1),
 QueryResult(query='21519793', tap=0.0, weight=5.0, T_q=1),
 QueryResult(query='7787496', tap=0.5833333333333334, weight=1.0, T_q=1),
 QueryResult(query='1303262', tap=0.27777777777777773, weight=1.0, T_q=2)]

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

TAP-k-1.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

TAP_k-1.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file TAP-k-1.0.tar.gz.

File metadata

  • Download URL: TAP-k-1.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/38.6.0 requests-toolbelt/0.8.0 tqdm/4.14.0 CPython/3.5.2

File hashes

Hashes for TAP-k-1.0.tar.gz
Algorithm Hash digest
SHA256 f688606dc42e9623acc1fd30e232529ee564c6cdd368d88281944c39594f1927
MD5 06a5b7ba29fd26490132008dbba86280
BLAKE2b-256 aa0e7cce98081806b9c32bf766ad4a0b8acffe67bfac56c88632ceed2e5b4050

See more details on using hashes here.

File details

Details for the file TAP_k-1.0-py3-none-any.whl.

File metadata

  • Download URL: TAP_k-1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/38.6.0 requests-toolbelt/0.8.0 tqdm/4.14.0 CPython/3.5.2

File hashes

Hashes for TAP_k-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 de1c2c07cae06aa5b6cb638ba61fd8f21db2a14f6796b6fb840bd723ba1f3ba6
MD5 df4e32c71f87966dc70281f5fac85f7c
BLAKE2b-256 2740cc6b4f00b127785bf30af8ab225db9e9f7c826b4ab2f80156355d6fa6962

See more details on using hashes here.

Supported by

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