Learn R Programming

HEMDAG (version 2.1.3)

AUPRC: AUPRC measures

Description

Function to compute Area under the Precision Recall Curve (AUPRC) through precrec package

Usage

AUPRC.single.class(target, pred, folds = NULL, seed = NULL)

AUPRC.single.over.classes(labels, predicted, folds = NULL, seed = NULL)

Arguments

target

vector of the true labels (0 negative, 1 positive examples)

pred

a numeric vector of the values of the predicted labels (scores)

folds

number of folds on which computing the AUPRC. If folds=NULL (def.), the one-shot AUPRC is computed, otherwise the AUPRC is computed averaged across folds.

seed

initialization seed for the random generator to create folds. Set seed only if folds\(\neq\)NULL. If seed\(\neq\)NULL and folds=NULL, the AUPRC averaged across folds is computed without seed initialization.

labels

matrix with the target multilabels: rows correspond to examples and columns to classes. \(target[i,j]=1\) if example \(i\) belongs to class \(j\), \(target[i,j]=0\) otherwise.

predicted

a numeric matrix with predicted values (scores): rows correspond to examples and columns to classes.

Value

AUPRC.single.class returns a numeric value corresponding to the AUPRC for the considered class; AUPR.single.over.classes returns a list with two elements:

  1. average: the average AUPRC across classes;

  2. per.class: a named vector with AUPRC for each class. Names correspond to classes.

Details

The AUPRC (for a single class or for a set of classes) is computed either one-shot or averaged across stratified folds.

AUPRC.single.class computes the AUPRC just for a given class.

AUPR.single.over.classes computes the AUPRC for a set of classes, including their average values across all the classes.

For all those classes having zero annotations, the AUPRC is set to 0. These classes are discarded in the computing of the AUPRC averaged across classes, both when the AUPRC is computed one-shot or averaged across stratified folds.

Names of rows and columns of labels and predicted matrix must be provided in the same order, otherwise a stop message is returned

Examples

Run this code
# NOT RUN {
data(labels);
data(scores);
data(graph);
root <- root.node(g);
L <- L[,-which(colnames(L)==root)];
S <- S[,-which(colnames(S)==root)];
PRC.single.class <- AUPRC.single.class(L[,3], S[,3], folds=5, seed=23);
PRC.over.classes <- AUPRC.single.over.classes(L, S, folds=5, seed=23);
# }

Run the code above in your browser using DataLab