PXR: Precision-Recall Measure

Description Usage Arguments Details Value Examples

Description

Functions to compute the Precision-Recall (PXR) values through precrec package.

Usage

1
2
3
4
5
precision.at.all.recall.levels.single.class(labels, scores)

precision.at.given.recall.levels.over.classes(target, predicted,
  folds = NULL, seed = NULL, recall.levels = seq(from = 0.1, to = 1,
  by = 0.1))

Arguments

labels

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

scores

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

target

matrix with the target multilabel: 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.

folds

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

seed

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

recall.levels

a vector with the desired recall levels (def: from:0.1, to:0.9, by:0.1).

Details

precision.at.all.recall.levels.single.class computes the precision at all recall levels just for a single class.

precision.at.given.recall.levels.over.classes computes the precision at fixed recall levels over classes.

Value

precision.at.all.recall.levels.single.class returns a two-columns matrix, representing a pair of precision and recall values. The first column is the precision, the second the recall; precision.at.given.recall.levels.over.classes returns a list with two elements:

  1. avgPXR: a vector with the average precision at different recall levels across classes;

  2. PXR: a matrix with the precision at different recall levels: rows are classes, columns precision at different recall levels;

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
data(labels);
data(scores);
data(graph);
root <- root.node(g);
L <- L[,-which(colnames(L)==root)];
S <- S[,-which(colnames(S)==root)];
labels <- L[,1];
scores <- S[,1];
rec.levels <- seq(from=0.25, to=1, by=0.25);
PXR.single <- precision.at.all.recall.levels.single.class(labels, scores);
PXR <- precision.at.given.recall.levels.over.classes(L, S, folds=5, seed=23, 
          recall.levels=rec.levels);

gecko515/HEMDAG documentation built on Oct. 18, 2019, 6:34 a.m.