getTPRandFPRbyThreshold: Estimates true and false positive rates

Description Usage Arguments Value Author(s) Examples

View source: R/getTPRandFPRbyThreshold.r

Description

This function provides the true and false positive rates (tpr and fpr) for a range of thresholds.

Usage

1
getTPRandFPRbyThreshold(validation_scores, label_pos = 1, thr_range = seq(0,1,0.01))

Arguments

validation_scores

data.frame scores estimated from the training set. It should be comprised of three columns (1. positive scores; 2. negative scores; 3.class).

label_pos

numeric value or factor indicating the positive label.

thr_range

a numerical vector of thresholds, ranged between 0 and 1. Default: seq(0.01,0.99,0.01).

Value

data.frame where each row has both (tpr and fpr) rates for each threshold value. This function varies the threshold from 0.01 to 0.99 with increments 0.01.

Author(s)

Everton Cherman <evertoncherman@gmail.com>

Andre Maletzke <andregustavom@gmail.com>

Examples

1
2
3
4
5
6
7
8
library(randomForest)
library(caret)
cv <- createFolds(aeAegypti$class, 2)
tr <- aeAegypti[cv$Fold1,]
validation <- aeAegypti[cv$Fold2,]
scorer <- randomForest(class~., data=tr, ntree=500)
scores <- cbind(predict(scorer, validation, type = c("prob")), validation$class)
TprFpr <- getTPRandFPRbyThreshold(scores)

mlquantify documentation built on Jan. 20, 2022, 5:07 p.m.