Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

An R library for accurate and fast calculations of Precision-Recall and ROC curves

License

NotificationsYou must be signed in to change notification settings

evalclass/precrec

Repository files navigation

R-CMD-checkcodecov.ioCodeFactorCRAN_Status_BadgeCRAN_Logs_Badge

The aim of theprecrec package is to provide an integrated platformthat enables robust performance evaluations of binary classifiers.Specifically,precrec offers accurate calculations of ROC (ReceiverOperator Characteristics) and precision-recall curves. All the maincalculations ofprecrec are implemented withC++/Rcpp.

Documentation

  • Package website – GitHub pagesthat contain all precrec documentation.

  • Introduction toprecrec– a package vignette that contains the descriptions of the functionswith several useful examples. View the vignette withvignette("introduction", package = "precrec") in R. The HTML versionis also available on theGitHubPages.

  • Help pages – all thefunctions including the S3 generics except forprint have their ownhelp pages with plenty of examples. View the main help page withhelp(package = "precrec") in R. The HTML version is also availableon theGitHub 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 fairlylarge dataset. It is much faster than most other tools that calculateROC and precision-recall curves.

3. Various evaluation metrics

In addition to precision-recall and ROC curves,precrec offers basicevaluation 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 aregiven. It automatically shows confidence bands about the averaged curvein the corresponding plot.

5. Calculation of partial AUCs and visualization of partial curves

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

6. Supporting functions

precrec provides several useful functions that lack in most otherevaluation tools.

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

Installation

  • Install the release version ofprecrec from CRAN withinstall.packages("precrec").

  • Alternatively, you can install a development version ofprecrec fromour GitHub repository. Toinstall 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. Installdevtools from CRAN withinstall.packages("devtools").

    3. Installprecrec from the GitHub repository withdevtools::install_github("evalclass/precrec").

Functions

Theprecrec 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, theprecrec package provides nine S3 generics for the S3object created by theevalmod function.N.B. The R languagespecifies S3 objects and S3 generic functions as part of the most basicobject-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 ofprecrec functions.

ROC and Precision-Recall calculations

Theevalmod function calculates ROC and Precision-Recall curves andreturns an S3 object.

library(precrec)# Load a test datasetdata(P10N10)# Calculate ROC and Precision-Recall curvessscurves<- evalmod(scores=P10N10$scores,labels=P10N10$labels)

Visualization of the curves

Theautoplot function outputs ROC and Precision-Recall curves by usingtheggplot2 package.

# The ggplot2 package is requiredlibrary(ggplot2)# Show ROC and Precision-Recall plotsautoplot(sscurves)

Citation

Precrec: fast and accurate precision-recall and ROC curve calculationsin R

Takaya Saito; Marc Rehmsmeier

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

doi:10.1093/bioinformatics/btw570

External links

About

An R library for accurate and fast calculations of Precision-Recall and ROC curves

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp