Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cwl-eval

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cwl-eval

An information retrieval evaluation script based on the C/W/L framework that is TREC Compatible and provides a replacement for INST_EVAL, RBP_EVAL, TBG_EVAL, UMeasure and TREC_EVAL scripts. All measurements are reported in the same units making all metrics directly comparable.

  • 1.0.12
  • PyPI
  • Socket score

Maintainers
1

C/W/L Evaluation Script

An evaluation script based on the C/W/L framework that is TREC Compatible and provides a replacement for INST_EVAL, RBP_EVAL, TBG_EVAL, UMeasure, TREC_EVAL.

Install

Install either via pip install cwl-eval or git clone https://github.com/ireval/cwl.git. cwl-eval requires Python 3 and Numpy.

Usage

Once you have installed the C/W/L Evaluation Framework using pip install, you should be able to use the cwl-eval as shown below. If you have used git clone to install the framework, then you will need to run cwl_eval.py directly.

Usage: cwl-eval <gain_file> <result_file> -c <cost_file> -m <metrics_file> -b <bibtex_file>

Usage: cwl-eval <gain_file> <result_file> -c <cost_file> -m <metrics_file>

Usage: cwl-eval <gain_file> <result_file>

Usage: cwl-eval -h
  • <gain_file> : A TREC Formatted Qrel File with relevance scores used as gains (float) Four column tab/space sep file with fields: topic_id unused doc_id gain

  • <cost_file> : Costs associated with element type

  • <cost_file> : If not specified, costs default to one for all elements Two column tab/space sep file with fields: element_type element_cost

  • <result_file> : A TREC Formatted Result File Six column tab/space sep file with fields: topic_id element_type doc_id rank score run_id

  • <metrics_file>: The list of metrics that are to be reported If not specified, a set of default metrics will be reported Tab/space sep file with fields: metric_name params

  • <bibtex_file>: Specify this file if you would like the BibTeX associated with the measures specified to be output to a file called <bibtex_file>

  • -n: Add -n flag to output column names (e.g. Topic, Metric, EU, ETU, EC, ETC, ED)

  • -r: Add -r flag to also output residuals for each measurement.

  • --max_n : Specify the depth of the calculation of the metrics (default=1000).

  • --max_gain : Specify the maximum value of the gain (default=1.0). Note some metrics have restrictions on the maximum allowable value. This is also used when computing the residuals.

  • --min_gain : Specify the minimum value of the gain (default=0.0). Note some metrics have restrictions on the minimum allowable value.

Example without using a cost file When no costs are specified the cost per item is assumed to be 1.0, and EC and I will be equal.

cwl-eval qrel_file result_file

Example with using a cost file

cwl-eval qrel_file result_file -c cost_file

Output A seven column tab/space separated file that contains:

  • Topic ID
  • Metric Name
  • Expected Utility Per Item (EU)
  • Expected Utility (ETU)
  • Expected Cost per Item (EC)
  • Expected Cost (ETC)
  • Expected Depth (ED)

If the -r flag is included, then another five columns will be included: ResEU, ResETU, ResEC, ResETC, ResED. These report the residual values for each of the measures (i.e. the difference between the best case and worse case for un-judged items).

CWL Citation

Please consider citing the following paper when using our code for your evaluations:

    @inproceedings{azzopardi2019cwl,
        author = {Azzopardi, Leif and Thomas, Paul and Moffat, Alistair},
        title = {cwl\_eval: An Evaluation Tool for Information Retrieval},
        booktitle = {Proc. of the 42nd International ACM SIGIR Conference},
        series = {SIGIR '19},
        year = {2019}
    } 

Metrics within CWL EVAL

For each of the metrics provided in cwl_eval.py, the user model for each measure has been extracted and encoded within the C/W/L framework.

All weightings have been converted to probabilities.

As a result, all metrics report a series of values (not a single value):

  • Expected Utility per item examined (EU),
  • Expected Total Utility (ETU),
  • Expected Cost per item examined (EC),
  • Expected Total Cost (ETC)
  • Expected number of items to be examined i.e expected depth (ED)

All the values are related, such that:

ETU = EU * ED

and

ETC = EC * ED

If the cost per item is 1.0, then the expected cost per item is 1.0, and the expected cost EC will be equal to I.

Costs can be specified in whatever unit is desired. i.e seconds, characters, words, etc.

List of Metrics

  • RR - (Expected) Reciprocal Rank
  • P@k - Precision At k
  • AP - Average Precision
  • RBP - Rank Biased Precision
  • INST T
  • INSQ T
  • NDCG@k - Normalized Discounted Cumulative Gain at k
  • BPM-Static - Bejewelled Player Model - Static
  • BPM-Dynamic - Bejewelled Player Model - Dynamic
  • UMeasure - U-Measure
  • TBG - Time Biased Gain
  • IFT-C1 - Information Foraging Theory (Goal)
  • IFT-C2 - Information Foraging Theory (Rate)
  • IFT-C1-C2 - Information Foraging Theory (Goal and Rate)
  • NERREq8 - Not/Nearly ERR(Eq8)@k using gain based stopping with truncation k
  • NERREq9 - Not/Nearly ERR(Eq9)@k using gain based stopping and discount with truncation k
  • NERREq10 - Not/Nearly ERR(Eq10)@phi using gain based stopping and RBP patience (phi)
  • NERREq11 - Not/Nearly ERR(Eq11)@T using gain based stopping and INST Goal (T)

Sample Output from cwl_eval.py where costs per item = 1.0

cwl-eval qrel_file result_file
TopicMetricEUETUECETCED
T1P@200.1503.0001.00020.00020.000
T1P@100.3003.0001.00010.00010.000
T1P@50.3601.8001.0005.0005.000
T1P@11.0001.0001.0001.0001.000
T1RBP@0.50.5661.1321.0002.0002.000
T1RBP@0.90.2142.1361.00010.00010.000
T1SDCG-k@100.3801.7261.0004.5444.544
T1SDCG-k@50.4611.3581.0002.9482.948
T1RR1.0001.0001.0001.0001.000
T1AP0.3971.9071.0004.8004.800
T1INST-T=20.4011.3031.0003.2423.247
T1INST-T=10.6801.0711.0001.5741.575
T1INSQ-T=20.3161.4281.0004.5094.525
T1INSQ-T=10.4651.1981.0002.5722.576
T1BPM-Static-T=1-K=10001.0001.0001.0001.0001.000
T1BPM-Static-T=1000-K=100.3003.0001.00010.00010.000
T1BPM-Static-T=1.2-K=100.4001.2001.0003.0003.000
T1BPM-Dynamic-T=1-K=1000-hb=1.0-hc=1.01.0001.0001.0001.0001.000
T1BPM-Dynamic-T=1000-K=10-hb=1.0-hc=1.00.3003.0001.00010.00010.000
T1BPM-Dynamic-T=1.2-K=10-hb=1.0-hc=1.00.4001.2001.0003.0003.000
T1U-L@500.1092.7721.00025.50025.500
T1U-L@100.3381.8601.0005.5005.500
T1TBG-H@220.0832.6761.00032.24232.242
T1IFT-C1-T@2.0-b1@0.9-R1@10.4561.3231.0002.9032.903
T1IFT-C1-T@2.0-b1@0.9-R1@100.3082.0781.0006.7386.738
T1IFT-C1-T@2.0-b1@0.9-R1@1000.2892.2241.0007.6987.698
T1IFT-C2-A@0.2-b2@0.9-R2@10.4631.2551.0002.7112.711
T1IFT-C2-A@0.2-b2@0.9-R2@100.2932.0401.0006.9656.965
T1IFT-C2-A@0.2-b2@0.9-R2@1000.1972.9941.00015.20815.208
T1IFT-C1-C2-T@2.0-b1@0.9-R1@10-A@2.0-b2@0.9-R2@100.3291.8041.0005.4875.487
T1IFT-C1-C2-T@2.0-b1@0.9-R1@100-A@2.0-b2@0.9-R2@1000.2892.2231.0007.6977.697

Sample Output from cwl-eval where costs are set based on cost_file

cwl-eval qrel_file result_file -c cost_file
TopicMetricEUETUECETCED
T1P@200.1503.0001.65033.00020.000
T1P@100.3003.0002.30023.00010.000
T1P@50.3601.8002.40012.0005.000
T1P@11.0001.0002.0002.0001.000
T1RBP@0.50.5661.1321.9513.9022.000
T1RBP@0.90.2142.1361.77617.76510.000
T1SDCG-k@100.3801.7262.1889.9434.544
T1SDCG-k@50.4611.3582.2246.5572.948
T1RR1.0001.0002.0002.0001.000
T1AP0.3971.9071.9589.4004.800
T1INST-T=20.4011.3031.8846.1133.247
T1INST-T=10.6801.0711.9553.0771.575
T1INSQ-T=20.3161.4281.7998.1254.525
T1INSQ-T=10.4651.1981.8874.8552.576
T1BPM-Static-T=1-K=10001.0001.0002.0002.0001.000
T1BPM-Static-T=1000-K=100.3601.8002.40012.0005.000
T1BPM-Static-T=1.2-K=100.4001.2001.6675.0003.000
T1BPM-Dynamic-T=1-K=1000-hb=1.0-hc=1.01.0001.0002.0002.0001.000
T1BPM-Dynamic-T=1000-K=10-hb=1.0-hc=1.00.3601.8002.40012.0005.000
T1BPM-Dynamic-T=1.2-K=10-hb=1.0-hc=1.00.4001.2001.6675.0003.000
T1U-L@500.1622.5521.65426.00015.720
T1U-L@100.4441.4202.0946.7003.200
T1TBG-H@220.1432.3392.04633.50816.375
T1IFT-C1-T@2.0-b1@0.9-R1@10.4561.3231.9715.7232.903
T1IFT-C1-T@2.0-b1@0.9-R1@100.3082.0782.08014.0176.738
T1IFT-C1-T@2.0-b1@0.9-R1@1000.2892.2242.06815.9227.698
T1IFT-C2-A@0.2-b2@0.9-R2@10.5161.1801.9584.4812.289
T1IFT-C2-A@0.2-b2@0.9-R2@100.4041.3682.0116.8023.382
T1IFT-C2-A@0.2-b2@0.9-R2@1000.3601.7862.38811.8324.954
T1IFT-C1-C2-T@2.0-b1@0.9-R1@10-A@2.0-b2@0.9-R2@100.4131.3611.9906.5523.293
T1IFT-C1-C2-T@2.0-b1@0.9-R1@100-A@2.0-b2@0.9-R2@1000.3601.7862.38811.8324.954

Using the metrics_file to specify the metrics

cwl-eval qrel_file result_file -m metrics_file

if a metrics_file is not specified, CWL Eval will default to a set of metrics defined in ruler/measures/cwl_ruler.py

If the metrics_file is specified, CWL Eval will instantiate and use the metrics listed. An example test_metrics_file is provided, which includes the following:

PrecisionCWLMetric(k=1)
PrecisionCWLMetric(k=5)
PrecisionCWLMetric(k=10)
PrecisionCWLMetric(k=20)
RBPCWLMetric(theta=0.9)
NDCGCWLMetric(k=10)
RRCWLMetric()
APCWLMetric()
INSTCWLMetric(T=1.0)
INSQCWLMetric(T=1.0)
BPMCWLMetric(T=1.0,K=20)
BPMCWLMetric(T=2.0,K=10)
BPMDCWLMetric(T=1,20)
BPMDCWLMetric(T=2.0,K=10)
UMeasureCWLMetric(L=50)
UMeasureCWLMetric(L=10)
TBGCWLMetric(halflife=22)
IFTGoalCWLMetric(T=2.0, b1=0.9, R1=10)
IFTGoalCWLMetric(T=2.0, b1=0.9, R1=100)
IFTRateCWLMetric(A=0.2, b2=0.9, R2=10)
IFTRateCWLMetric(A=0.2, b2=0.9, R2=100)
IFTGoalRateCWLMetric(T=2.0, b1=0.9, R1=10, A=0.2, b2=0.9, R2=10)
IFTGoalRateCWLMetric(T=2.0, b1=0.9, R1=100, A=0.2, b2=0.9, R2=100)
NERReq8CWLMetric(k=10)
NERReq9CWLMetric(k=10)
NERReq10CWLMetric(phi=0.8)
NERReq11CWLMetric(T=2.0)

To specify which metric you desire, inspect the metrics classes in ruler/measures/ to see what metrics are available, and how the parameterize them.

For example if you only wanted Precision Based Measures then you can list them as follows:

PrecisionCWLMetric(1)
PrecisionCWLMetric(2)
PrecisionCWLMetric(3)
PrecisionCWLMetric(4)
PrecisionCWLMetric(5)
PrecisionCWLMetric(6)
PrecisionCWLMetric(7)
PrecisionCWLMetric(8)
PrecisionCWLMetric(9)
PrecisionCWLMetric(10)
PrecisionCWLMetric(11)
PrecisionCWLMetric(12)
PrecisionCWLMetric(13)
PrecisionCWLMetric(14)
PrecisionCWLMetric(15)
PrecisionCWLMetric(16)
PrecisionCWLMetric(17)
PrecisionCWLMetric(18)
PrecisionCWLMetric(19)
PrecisionCWLMetric(20)

While if you only wanted Rank Biased Precision Measures, then you can vary the patience parameter:

RBPCWLMetric(0.1)
RBPCWLMetric(0.2)
RBPCWLMetric(0.3)
RBPCWLMetric(0.4)
RBPCWLMetric(0.5)
RBPCWLMetric(0.6)
RBPCWLMetric(0.7)
RBPCWLMetric(0.8)
RBPCWLMetric(0.9)
RBPCWLMetric(0.95)
RBPCWLMetric(0.99)

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc