Learn R Programming

HEMDAG (version 2.1.3)

Multilabel.F.measure: 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 matrix,matrix F.measure.multilabel(target, predicted, b.per.example = FALSE)

Arguments

target

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 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

boolean.

  • TRUE: results are returned for each example;

  • FALSE: only the average results are 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 the 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)

Details

Names of rows and columns of target 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)];
S[S>0.7] <- 1;
S[S<0.7] <- 0;
FMM <- F.measure.multilabel(L,S);
# }

Run the code above in your browser using DataLab