compute_score_metrics.Rd
Compute Different Metrics Based on Scores
compute_score_metrics(
land1,
land2,
score,
addNA = TRUE,
na.rm = TRUE,
include = NULL,
out_names = NULL
)
(numeric) vector with land ids of bullet 1
(numeric) vector with land ids of bullet 2
numeric vector of scores to be summarized into a single number
logical value. In case of missing lands, are scores set to 0 (addNA = FALSE) or set to NA (addNA = TRUE)
a logical value indicating whether NA values should be stripped before the computation proceeds
a character vector specifying which metrics to be included in the result; if include = NULL
, including
all metrics
a character vector specifying the variable names of each metric; if out_names = NULL
, using the default names
a data frame containing values of the metrics
By default, this helper function computes four metrics.
diff
: the difference between the mean score of the foreground phase and the mean score of the background phases
diff.med
: the difference between the median score of the foreground phase and the median score of the background phases
max
: the max score
maxbar
: the mean score of the foreground phase
library(tidyverse)
data("bullets")
lands <- unique(bullets$bulletland)
comparisons <- data.frame(expand.grid(land1 = lands[1:6], land2 = lands[7:12]),
stringsAsFactors = FALSE)
comparisons <- comparisons %>%
left_join(bullets %>% select(bulletland, sig1=sigs),
by = c("land1" = "bulletland")) %>%
left_join(bullets %>% select(bulletland, sig2=sigs),
by = c("land2" = "bulletland"))
comparisons <- comparisons %>% mutate(
cmps = purrr::map2(sig1, sig2, .f = function(x, y) {
extract_feature_cmps(x$sig, y$sig, include = "full_result")
})
)
comparisons <- comparisons %>%
mutate(
cmps_score = sapply(comparisons$cmps, function(x) x$CMPS_score),
cmps_nseg = sapply(comparisons$cmps, function(x) x$nseg)
)
cp1 <- comparisons %>% select(land1, land2, cmps_score, cmps_nseg)
cp1 <- cp1 %>% mutate(
land1idx = land1 %>% str_sub(-1, -1) %>% as.numeric(),
land2idx = land2 %>% str_sub(-1, -1) %>% as.numeric()
)
with(cp1, {
compute_score_metrics(land1idx, land2idx, cmps_score)
})
#> diff diff.med max maxbar
#> 1 10.96667 13.5 17 12.5