Last chance! 50% off unlimited learning
Sale ends in
This function will return the utility maximizing threshold for future predictions along with the data generated to estimate the threshold
threshOptim(data, actTar = "target", predTar = "p1", tpProfit = 0,
tnProfit = 0, fpProfit = -1, fnProfit = -2, MinThresh = 0.001,
MaxThresh = 0.999, ThresholdPrecision = 0.001)
data is the data table you are building the modeling on
The column name where the actual target variable is located (in binary form)
The column name where the predicted values are located
This is the utility for generating a true positive prediction
This is the utility for generating a true negative prediction
This is the cost of generating a false positive prediction
This is the cost of generating a false negative prediction
Minimum value to consider for model threshold
Maximum value to consider for model threshold
Incrementing value in search
Optimal threshold and corresponding utilities for the range of thresholds tested
Other Model Evaluation and Interpretation: EvalPlot
,
ParDepCalPlots
,
RedYellowGreen
# NOT RUN {
data <- data.table::data.table(Target = runif(10))
data[, x1 := qnorm(Target)]
data[, x2 := runif(10)]
data[, Predict := log(pnorm(0.85 * x1 +
sqrt(1-0.85^2) * qnorm(x2)))]
data[, ':=' (x1 = NULL, x2 = NULL)]
data <- threshOptim(data = data,
actTar = "Target",
predTar = "Predict",
tpProfit = 0,
tnProfit = 0,
fpProfit = -1,
fnProfit = -2,
MinThresh = 0.001,
MaxThresh = 0.999,
ThresholdPrecision = 0.001)
optimalThreshold <- data$Thresholds
allResults <- data$EvaluationTable
# }
Run the code above in your browser using DataLab