Skip to contents

Computes the relation of score before a change (e.g. PFI, LOCO, ...) and after.

Usage

compute_score(
  scores_pre,
  scores_post,
  relation = c("difference", "ratio"),
  minimize = TRUE
)

Arguments

scores_pre

(numeric()) Score before change.

scores_post

(numeric()) Score after change.

relation

(character(1), "difference") Either "difference" or "ratio". If "difference", then scores_post - scores_pre is computed, otherwise scores_post / scores_pre.

minimize

(logical(1), TRUE) Whether the score needs to be minimized (e.g. RMSE) or maximized (e.g. AUC).

Value

A numeric vector of the same length as scores_pre and scores_post

Details

If minimize == TRUE, then scores_post - scores_pre is computed for relation == "difference", otherwise scores_pre - scores_post is given. If minimize == FALSE, then scores_pre - scores_post is computed.

Examples


pre = rnorm(10)
post = pre + runif(10)

compute_score(pre, post)
#>  [1] 0.3837898 0.1809239 0.6372512 0.5597414 0.8500275 0.6701602 0.6118011
#>  [8] 0.9065461 0.3120600 0.5973761
compute_score(pre, post, "ratio")
#>  [1]  0.83843776 -2.02913284  2.50339370  1.39479532  1.56034381  1.70347188
#>  [7] -0.20235432  0.02680938  0.65095340  1.85102402
compute_score(pre, post, minimize = FALSE)
#>  [1] -0.3837898 -0.1809239 -0.6372512 -0.5597414 -0.8500275 -0.6701602
#>  [7] -0.6118011 -0.9065461 -0.3120600 -0.5973761