MyNixOS website logo
Description

Calculate Accurate Precision-Recall and ROC (Receiver Operator Characteristics).

Accurate calculations and visualization of precision-recall and ROC (Receiver Operator Characteristics) curves. Saito and Rehmsmeier (2015) <doi:10.1371/journal.pone.0118432>.

Precrec

R-CMD-check AppVeyor BuildStatus codecov.io CodeFactor CRAN_Status_Badge CRAN_Logs_Badge

The aim of the precrec package is to provide an integrated platform that enables robust performance evaluations of binary classifiers. Specifically, precrec offers accurate calculations of ROC (Receiver Operator Characteristics) and precision-recall curves. All the main calculations of precrec are implemented with C++/Rcpp.

Documentation

  • Package website – GitHub pages that contain all precrec documentation.

  • Introduction to precrec – a package vignette that contains the descriptions of the functions with several useful examples. View the vignette with vignette("introduction", package = "precrec") in R. The HTML version is also available on the GitHub Pages.

  • Help pages – all the functions including the S3 generics except for print have their own help pages with plenty of examples. View the main help page with help(package = "precrec") in R. The HTML version is also available on the GitHub Pages.

Six key features of precrec

1. Accurate curve calculations

precrec provides accurate precision-recall curves.

  • Non-linear interpolation
  • Elongation to the y-axis to estimate the first point when necessary
  • Use of score-wise threshold values instead of fixed bins

precrec also calculates AUC scores with high accuracy.

2. Super fast

precrec calculates curves in a matter of seconds even for a fairly large dataset. It is much faster than most other tools that calculate ROC and precision-recall curves.

3. Various evaluation metrics

In addition to precision-recall and ROC curves, precrec offers basic evaluation measures.

  • Error rate
  • Accuracy
  • Specificity
  • Sensitivity, true positive rate (TPR), recall
  • Precision, positive predictive value (PPV)
  • Matthews correlation coefficient
  • F-score

4. Confidence interval band

precrec calculates confidence intervals when multiple test sets are given. It automatically shows confidence bands about the averaged curve in the corresponding plot.

5. Calculation of partial AUCs and visualization of partial curves

precrec calculates partial AUCs for specified x and y ranges. It can also draw partial ROC and precision-recall curves for the specified ranges.

6. Supporting functions

precrec provides several useful functions that lack in most other evaluation tools.

  • Handling multiple models and multiple test sets
  • Handling tied scores and missing scores
  • Pre- and post-process functions of simple data preparation and curve analysis

Installation

  • Install the release version of precrec from CRAN with install.packages("precrec").

  • Alternatively, you can install a development version of precrec from our GitHub repository. To install it:

    1. Make sure you have a working development environment.

      • Windows: Install Rtools (available on the CRAN website).
      • Mac: Install Xcode from the Mac App Store.
      • Linux: Install a compiler and various development libraries (details vary across different flavors of Linux).
    2. Install devtools from CRAN with install.packages("devtools").

    3. Install precrec from the GitHub repository with devtools::install_github("evalclass/precrec").

Functions

The precrec package provides the following six functions.

FunctionDescription
evalmodMain function to calculate evaluation measures
mmdataReformat input data for performance evaluation calculation
join_scoresJoin scores of multiple models into a list
join_labelsJoin observed labels of multiple test datasets into a list
create_sim_samplesCreate random samples for simulations
format_nfoldCreate n-fold cross validation dataset from data frame

Moreover, the precrec package provides nine S3 generics for the S3 object created by the evalmod function. N.B. The R language specifies S3 objects and S3 generic functions as part of the most basic object-oriented system in R.

S3 genericPackageDescription
printbasePrint the calculation results and the summary of the test data
as.data.framebaseConvert a precrec object to a data frame
plotgraphicsPlot performance evaluation measures
autoplotggplot2Plot performance evaluation measures with ggplot2
fortifyggplot2Prepare a data frame for ggplot2
aucprecrecMake a data frame with AUC scores
partprecrecCalculate partial curves and partial AUC scores
paucprecrecMake a data frame with pAUC scores
auc_ciprecrecCalculate confidence intervals of AUC scores

Examples

Following two examples show the basic usage of precrec functions.

ROC and Precision-Recall calculations

The evalmod function calculates ROC and Precision-Recall curves and returns an S3 object.

library(precrec)

# Load a test dataset
data(P10N10)

# Calculate ROC and Precision-Recall curves
sscurves <- evalmod(scores = P10N10$scores, labels = P10N10$labels)

Visualization of the curves

The autoplot function outputs ROC and Precision-Recall curves by using the ggplot2 package.

# The ggplot2 package is required
library(ggplot2)

# Show ROC and Precision-Recall plots
autoplot(sscurves)

Citation

Precrec: fast and accurate precision-recall and ROC curve calculations in R

Takaya Saito; Marc Rehmsmeier

Bioinformatics 2017; 33 (1): 145-147.

doi: 10.1093/bioinformatics/btw570

External links

Metadata

Version

0.14.4

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows