R library for common information retrieval metrics
Перейти к файлу
Paul Thomas b0930c33a5
Merge pull request #3 from microsoft/users/GitHubPolicyService/2b057b03-63bc-451e-992f-a22075b96c31
Adding Microsoft SECURITY.MD
2023-06-05 20:06:42 +10:00
R Calculate residuals for all metrics, not just "infinite tail" and not just static metrics 2018-09-25 16:55:15 +10:00
man Calculate residuals for all metrics, not just "infinite tail" and not just static metrics 2018-09-25 16:55:15 +10:00
tests Calculate residuals for all metrics, not just "infinite tail" and not just static metrics 2018-09-25 16:55:15 +10:00
vignettes removed use of purrr 2018-10-11 13:16:57 -04:00
.Rbuildignore Initial implementation and tests for AP, ERR, INST, P, RBP, RR, SDCG 2018-04-20 11:33:45 +10:00
.gitignore checked the build-ability of the vignette 2018-10-11 13:11:45 -04:00
DESCRIPTION Update DESCRIPTION 2018-10-15 13:32:14 +11:00
LICENSE Initial commit 2018-04-19 16:46:33 -07:00
NAMESPACE Add implemenation of IFT, from Azzopardi et al. SIGIR'18 2018-04-26 11:21:19 +10:00
README.md Update README.md 2018-11-05 13:45:27 -08:00
SECURITY.md Microsoft mandatory file 2023-06-02 19:08:29 +00:00
irmetrics.Rproj Add implemenation of IFT, from Azzopardi et al. SIGIR'18 2018-04-26 11:21:19 +10:00

README.md

IR metrics for R

This is a small library for implementing several standard "test collection" or "offline" evaluation measures for search systems. It uses the C/W/L framework described by Moffat et al. and implements:

  • Precision at k (P)
  • Average precision (AP)
  • Reciprocal rank (RR)
  • Expected reciprocal rank (ERR)
  • Rank-biased precision (RBP)
  • Scaled discounted cumulative gain (SDCG)
  • INST

Install with

devtools::install_github("Microsoft/irmetrics-r")
library(irmetrics)

Example:

# a gain or relevance vector: how good each retrieved thing is, in the order they appear
gains <- c(1, 0, 0, 0.5, 1)

# precision at 1 is perfect
P(gains, k=1) #> 1
# precision at 3 is one-third
P(gains, k=3) #> 0.33

# rank-biased precision, with persistence 0.7
RBP(gains, p=0.7) #> 0.42

# Investigate the weight vector, see the metric accumulate, ...
str(INST(gains, T=1))
#> List of 8
#>  $ metric    : num 0.678
#>  $ C         : num [1:5] 0.25 0.444 0.562 0.605 0.605
#>  $ W         : num [1:5] 0.6345 0.1586 0.0705 0.0397 0.024
#>  $ gain      : num [1:5] 1 0 0 0.5 1
#>  $ cum.metric: num [1:5] 0.634 0.634 0.634 0.654 0.678
#>  $ i         : int [1:5] 1 2 3 4 5
#>  $ residual  : num 0.0728

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.