profit_thresholds: Find optimal threshold for churn prediction (class)

Description Usage Arguments Examples

View source: R/profit_thresholds.R

Description

Finds the optimal threshold (from a business perspective) for classifying churners.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
profit_thresholds(
  x,
  var_cost = 0,
  prob_accept = 1,
  tp_val = 0,
  fp_val = 0,
  tn_val = 0,
  fn_val = 0,
  prob_col = NA,
  truth_col = NA
)

Arguments

x

A data frame containing predicted probabilities of a target event and the actual outcome/class.

var_cost

Variable cost (e.g. of a campaign offer)

prob_accept

Probability of offer being accepted. Defaults to 1.

tp_val

The average value of a True Positive. 'var_cost' is automatically subtracted.

fp_val

The average cost of a False Positive. 'var_cost' is automatically subtracted.

tn_val

The average value of a True Negative.

fn_val

The average cost of a False Negative.

prob_col

The unquoted name of the column with probabilities of the event of interest.

truth_col

The unquoted name of the column with the actual outcome/class. Possible values are 'Yes' and 'No'.

#' @return A data frame with the following columns:

threshold = prediction thresholds
payoff = calculated profit for each threshold

Examples

1
2
3
4
5
6
7
8
9
profit_thresholds(predictions,
   var_cost    = 100,
   prob_accept = .8,
   tp_val      = 2000,
   fp_val      = 0,
   tn_val      = 0,
   fn_val      = -2000,
   prob_col    = Yes,
   truth_col   = Churn)

modelimpact documentation built on May 6, 2021, 9:06 a.m.