netbenchmark (version 1.4.2)

comp.metr: Compute metrics

Description

A group of functions to plot precision-recall and ROC curves and to compute f-scores from the matrix returned by the evaluate function.

Usage

fscore(table, beta=1)
    auroc(table,k=-1)
    aupr(table,k=-1)
    pr.plot(table,device=-1,...)
    roc.plot(table,device=-1,...)

Arguments

table
This is the matrix returned by the evaluate function where columns contain the confusion matrix TP,FP,TN,FN values. - see evaluate.
beta
Numeric used as the weight of the recall in the f-score formula - see details. The default value of this argument is -1, meaning precision as important as recall.
k
Numeric used as the index to compute the area under the curve until that point- see details. The default value of this argument is -1, meaning that the whole area under the curve is computed
device
The device to be used. This parameter allows the user to plot precision-recall and receiver operating characteristic curves for various inference algorithms on the same plotting window - see examples.
...
Arguments passed to plot.

Value

  • The function roc.plot (pr.plot) plots the ROC-curve (PR-curve) and returns the device associated with the plotting window. The function auroc (aupr) computes the area under the ROC-curve (PR-curve) using the trapezoidal approximation until point k. The function fscore returns fscores according to the confusion matrices contained in the 'table' argument - see details.

Details

A confusion matrix contains FP,TP,FN,FP values.
  • "true positive rate"$tpr = \frac{TP}{TN+TP}$
  • "false positive rate"$fpr = \frac{FP}{FN+FP}$
  • "precision"$p = \frac{TP}{FP+TP}$
  • "recall"$r = \frac{TP}{TP+FN}$
  • "f-beta-score"$F_\beta = (1+\beta) \frac{p r} {r + \beta p}${Fbeta = (1+beta) * p*r/(r + beta*p)}

See Also

evaluate, plot

Examples

Run this code
# Inference
    Net <- cor(syntren300.data)
    # Validation
    tbl <-  evaluate(Net,syntren300.net)
    # Plot PR-Curves
    max(fscore(tbl))
    dev <- pr.plot(tbl, col="green", type="l")
    aupr(tbl)
    idx <- which.max(fscore(tbl))

Run the code above in your browser using DataLab