check_utility_calc: Check a few things we expect to be true for the utility...

Description Usage Arguments Value Examples

View source: R/model_utility.R

Description

Utility to inspect a utility frame for some debugging.

Usage

1
2
3
4
5
6
7
check_utility_calc(
  values,
  ...,
  orig_score = NULL,
  orig_outcome = NULL,
  constant_utilities = FALSE
)

Arguments

values

model_utility result

...

Not used, forces later argument to be specified by name.

constant_utilities

logical, if TRUE assume utilities were constant per-row.

Value

NULL if okay, else a string describing the problem.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
d <- data.frame(
  predicted_probability = c(0, 0.5, 0.5, 0.5),
  made_purchase = c(FALSE, TRUE, FALSE, FALSE),
  false_positive_value = -5,    # acting on any predicted positive costs $5
  true_positive_value = 95,     # revenue on a true positive is $100 minus action cost
  true_negative_value = 0.001,  # true negatives have no value in our application
                                # but just give ourselves a small reward for being right
  false_negative_value = -0.01  # adding a small notional tax for false negatives,
                                # don't want our competitor getting these accounts.
  )

values <- model_utility(d, 'predicted_probability', 'made_purchase')
check_utility_calc(values,
                   orig_score = d$predicted_probability,
                   orig_outcome = d$made_purchase)

sigr documentation built on June 12, 2021, 9:07 a.m.