Learn R Programming

cutpointr (version 1.1.2)

total_utility: Calculate the total utility

Description

Calculate the total utility from true positives, false positives, true negatives and false negatives. total_utility = utility_tp * tp + utility_tn * tn - cost_fp * fp - cost_fn * fn The inputs must be vectors of equal length.

Usage

total_utility(
  tp,
  fp,
  tn,
  fn,
  utility_tp = 1,
  utility_tn = 1,
  cost_fp = 1,
  cost_fn = 1,
  ...
)

Arguments

tp

(numeric) number of true positives.

fp

(numeric) number of false positives.

tn

(numeric) number of true negatives.

fn

(numeric) number of false negatives.

utility_tp

(numeric) the utility of a true positive

utility_tn

(numeric) the utility of a true negative

cost_fp

(numeric) the cost of a false positive

cost_fn

(numeric) the cost of a false negative

...

for capturing additional arguments passed by method.

See Also

Other metric functions: F1_score(), Jaccard(), abs_d_ppv_npv(), abs_d_sens_spec(), accuracy(), cohens_kappa(), cutpoint(), false_omission_rate(), metric_constrain(), misclassification_cost(), npv(), odds_ratio(), p_chisquared(), plr(), ppv(), precision(), prod_ppv_npv(), prod_sens_spec(), recall(), risk_ratio(), roc01(), sensitivity(), specificity(), sum_ppv_npv(), sum_sens_spec(), tpr(), tp(), youden()

Examples

Run this code
# NOT RUN {
total_utility(10, 5, 20, 10, utility_tp = 3, utility_tn = 3, cost_fp = 1, cost_fn = 5)
total_utility(c(10, 8), c(5, 7), c(20, 12), c(10, 18),
              utility_tp = 3, utility_tn = 3, cost_fp = 1, cost_fn = 5)
# }

Run the code above in your browser using DataLab