Skip to main content

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)]

Metadata

Release files for TAP-k 1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for TAP-k 1.0
File Size Uploaded
TAP-k-1.0.tar.gz 9.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for TAP-k 1.0
File Interpreter ABI Platform
TAP_k-1.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.9 kB

Release files / TAP-k-1.0.tar.gz

Download URL TAP-k-1.0.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f688606dc42e9623acc1fd30e232529ee564c6cdd368d88281944c39594f1927
BLAKE2b-256 checksum
How to use checksums
aa0e7cce98081806b9c32bf766ad4a0b8acffe67bfac56c88632ceed2e5b4050
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / TAP_k-1.0-py3-none-any.whl

Download URL TAP_k-1.0-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de1c2c07cae06aa5b6cb638ba61fd8f21db2a14f6796b6fb840bd723ba1f3ba6
BLAKE2b-256 checksum
How to use checksums
2740cc6b4f00b127785bf30af8ab225db9e9f7c826b4ab2f80156355d6fa6962
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page