cost: Calculate a cost function.

Description Usage Arguments Details Value Examples

Description

Given a receiver operating characteristic (ROC) curve, calculates the cost function with given weights on false positives and false negatives respectively.

Usage

1
cost(fpr, tpr, fp.weight = 1)

Arguments

fpr

A numeric vector, representing the false positive rate (FPR) of points on a ROC curve.

tpr

A numeric vector, representing the true positive rate (TPR) of points on a ROC curve, assumed to be corresponding to those represented in fpr.

fp.weight

A weight (numeric value) representing the relative importance (cost) of a false positive, relative to a false negative. So a value of 2 would indicate a false positive is twice as ‘bad’ as a false negative, a value of 0.5 would indicate it is half as bad.

Details

Arguments fpr and tpr must contain only values between 0 and 1, without any NA or NaN values, and must be the same length. Otherwise, cost will throw an appropriate error.

Value

A vector of costs.

Examples

1
2
3
roc.df = roc(c(1, 2, 3, 4, 4, 5), c(FALSE, FALSE, FALSE, TRUE, FALSE, TRUE))
cost(roc.df$FPR, roc.df$TPR)
cost(roc.df$FPR, roc.df$TPR, 2)

Armadilloa16/roc documentation built on May 5, 2019, 7:06 a.m.