Learn R Programming

RemixAutoML (version 0.11.0)

threshOptim: Utility maximizing thresholds for binary classification

Description

This function will return the utility maximizing threshold for future predictions along with the data generated to estimate the threshold

Usage

threshOptim(data, actTar = "target", predTar = "p1", tpProfit = 0,
  tnProfit = 0, fpProfit = -1, fnProfit = -2, MinThresh = 0.001,
  MaxThresh = 0.999, ThresholdPrecision = 0.001)

Arguments

data

data is the data table you are building the modeling on

actTar

The column name where the actual target variable is located (in binary form)

predTar

The column name where the predicted values are located

tpProfit

This is the utility for generating a true positive prediction

tnProfit

This is the utility for generating a true negative prediction

fpProfit

This is the cost of generating a false positive prediction

fnProfit

This is the cost of generating a false negative prediction

MinThresh

Minimum value to consider for model threshold

MaxThresh

Maximum value to consider for model threshold

ThresholdPrecision

Incrementing value in search

Value

Optimal threshold and corresponding utilities for the range of thresholds tested

See Also

Other Model Evaluation and Interpretation: EvalPlot, ParDepCalPlots, RedYellowGreen

Examples

Run this code
# 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