Title: | Functions to Assess the Business Impact of Churn Prediction Models |
---|---|
Description: | Calculate the financial impact of using a churn model in terms of cost, revenue, profit and return on investment. |
Authors: | Peer Christensen |
Maintainer: | Peer Christensen <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.0 |
Built: | 2024-10-25 02:44:01 UTC |
Source: | https://github.com/peerchristensen/modelimpact |
Calculates cost and revenue after sorting observations.
cost_revenue( x, fixed_cost = 0, var_cost = 0, tp_val = 0, prob_col = NA, truth_col = NA )
cost_revenue( x, fixed_cost = 0, var_cost = 0, tp_val = 0, prob_col = NA, truth_col = NA )
x |
A data frame containing predicted probabilities of a target event and the actual outcome/class. |
fixed_cost |
Fixed cost (e.g. of a campaign) |
var_cost |
Variable cost (e.g. discount offered) |
tp_val |
The average value of a True Positive |
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'. |
A data frame with the following columns:
row = row numbers
pct = percentiles
cost_sum = cumulated costs
cum_rev = cumulated revenue
cost_revenue(predictions, fixed_cost = 1000, var_cost = 100, tp_val = 2000, prob_col = Yes, truth_col = Churn)
cost_revenue(predictions, fixed_cost = 1000, var_cost = 100, tp_val = 2000, prob_col = Yes, truth_col = Churn)
A dataset containing 2145 observations with four columns specifying predicted probabilities and predicted and actual class.
predictions
predictions
A data frame with 2145 rows and 4 variables:
Predicted class
Predicted probability of class 'No'
Predicted probability of class 'Yes'
Actual class
...
Calculates profit after sorting observations.
profit( x, fixed_cost = 0, var_cost = 0, tp_val = 0, prob_col = NA, truth_col = NA )
profit( x, fixed_cost = 0, var_cost = 0, tp_val = 0, prob_col = NA, truth_col = NA )
x |
A data frame containing predicted probabilities of a target event and the actual outcome/class. |
fixed_cost |
Fixed cost (e.g. of a campaign) |
var_cost |
Variable cost (e.g. discount offered) |
tp_val |
The average value of a True Positive |
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'. |
A data frame with the following columns:
row = row numbers
pct = percentiles
profit = profit for number of rows selected
profit(predictions, fixed_cost = 1000, var_cost = 100, tp_val = 2000, prob_col = Yes, truth_col = Churn)
profit(predictions, fixed_cost = 1000, var_cost = 100, tp_val = 2000, prob_col = Yes, truth_col = Churn)
Finds the optimal threshold (from a business perspective) for classifying churners.
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 )
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 )
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 |
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)
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)
Calculates ROI after sorting observations with ROI defined as (Current Value - Start Value) / Start Value
roi(x, fixed_cost = 0, var_cost = 0, tp_val = 0, prob_col = NA, truth_col = NA)
roi(x, fixed_cost = 0, var_cost = 0, tp_val = 0, prob_col = NA, truth_col = NA)
x |
A data frame containing predicted probabilities of a target event and the actual outcome/class. |
fixed_cost |
Fixed cost (e.g. of a campaign) |
var_cost |
Variable cost (e.g. discount offered) |
tp_val |
The average value of a True Positive |
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'. |
A data frame with the following columns:
row = row numbers
pct = percentiles
cum_rev = cumulated revenue
cost_sum = cumulated costs
roi = return on investment
roi(predictions, fixed_cost = 1000, var_cost = 100, tp_val = 2000, prob_col = Yes, truth_col = Churn)
roi(predictions, fixed_cost = 1000, var_cost = 100, tp_val = 2000, prob_col = Yes, truth_col = Churn)