Learn R Programming

mlquantify (version 0.2.0)

getTPRandFPRbyThreshold: Estimates true and false positive rates

Description

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

Usage

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.

Examples

Run this code
# NOT RUN {
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)
# }

Run the code above in your browser using DataLab