multilabel.F.measure: multilabel F-measure

multilabel.F.measureR Documentation

multilabel F-measure

Description

Method for computing Precision, Recall, Specificity, Accuracy and F-measure for multiclass and multilabel classification.

Usage

F.measure.multilabel(target, predicted, b.per.example = FALSE)

## S4 method for signature 'matrix,matrix'
F.measure.multilabel(target, predicted, 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 discrete predicted values: rows correspond to examples and columns to classes. predicted[i,j]=1 if example i is predicted belonging to class j, target[i,j]=0 otherwise.

b.per.example

a boolean value.

  • TRUE: results are returned for each example;

  • FALSE: only the average results are returned;

Details

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:

  • b.per.example==FALSE: a list with a single element average. A named vector with average precision (P), recall (R), specificity (S), F-measure (F), average F-measure (avF) and Accuracy (A) across examples. F is the F-measure computed as the harmonic mean between the average precision and recall; av.F is the F-measure computed as average across examples;

  • b.per.example==FALSE: a list with two elements:

    1. average: a named vector with average precision (P), recall (R), specificity (S), F-measure (F), average F-measure (avF) and Accuracy (A) across examples;

    2. per.example: a named matrix with the Precision (P), Recall (R), Specificity (S), Accuracy (A), F-measure (F) and av.F-measure (av.F) for each example. Row names correspond to examples, column names correspond respectively to Precision (P), Recall (R), Specificity (S), Accuracy (A), F-measure (F) and av.F-measure (av.F);

Examples

data(labels);
data(scores);
data(graph);
root <- root.node(g);
L <- L[,-which(colnames(L)==root)];
S <- S[,-which(colnames(S)==root)];
S[S>0.7] <- 1;
S[S<0.7] <- 0;
fscore <- F.measure.multilabel(L,S);

marconotaro/hemdag documentation built on Nov. 21, 2024, 10:05 p.m.