find.best.f: Best hierarchical F-score

Description Usage Arguments Details Value Examples

View source: R/perf.meas.R

Description

Function to select the best hierarchical F-score by choosing an appropriate threshold in the scores.

Usage

1
2
find.best.f(target, predicted, n.round = 3, f.criterion = "F",
  verbose = TRUE, b.per.example = FALSE)

Arguments

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 continuous predicted values (scores): rows correspond to examples and columns to classes.

n.round

number of rounding digits to be applied to predicted (default=3).

f.criterion

character. Type of F-measure to be used to select the best F-score. There are two possibilities:

  1. F (def.) corresponds to the harmonic mean between the average precision and recall;

  2. avF corresponds to the per-example F-score averaged across all the examples;

verbose

boolean. If TRUE (def.) the number of iterations are printed on stdout.

b.per.example

boolean.

  • TRUE: results are returned for each example;

  • FALSE: only the average results are returned;

Details

All the examples having no positive annotations are discarded. The predicted scores matrix (predicted) is rounded according to parameter n.round and all the values of predicted are divided by max(predicted). Then all the thresholds corresponding to all the different values included in predicted are attempted, and the threshold leading to the maximum F-measure is selected.

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

Value

Two different outputs respect to the input parameter b.per.example:

Examples

1
2
3
4
5
6
7
data(graph);
data(labels);
data(scores);
root <- root.node(g);
L <- L[,-which(colnames(L)==root)];
S <- S[,-which(colnames(S)==root)];
FMM <- find.best.f(L, S, n.round=3, f.criterion="F", verbose=TRUE, b.per.example=TRUE);

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