ROC curve calculation ROCR package is taken equal to or greater than greater than the cutoff cutoff

Find the corresponding code is as follows

.compute.unnormalized.roc.curve
function (predictions, labels) 
{
    pos.label <- levels(labels)[2]
    neg.label <- levels(labels)[1]
    pred.order <- order(predictions, decreasing = TRUE)
    predictions.sorted <- predictions[pred.order]
    tp <- cumsum(labels[pred.order] == pos.label)
    fp <- cumsum(labels[pred.order] == neg.label)
    dups <- rev(duplicated(rev(predictions.sorted)))
    tp <- c(0, tp[!dups])
    fp <- c(0, fp[!dups])
    cutoffs <- c(Inf, predictions.sorted[!dups])
    return(list(cutoffs = cutoffs, fp = fp, tp = tp))
}

Can be seen first by descending order, then the cumulative value of the current positive position and the position before. Therefore, when calculating TP, TN and other indicators, taken cutoff greater than or equal

Guess you like

Origin www.cnblogs.com/ywliao/p/11238994.html