Skip to contents

Puts the SCORE column of one or more score tables onto a common scale, so that [combine_scores()] adds comparable quantities. Every method is a monotone transformation applied identically to every candidate pair, so the ranking *within* a single score table is untouched; only the relative influence of the tables on their sum changes.

Usage

normalize_scores(scores, method = c("range", "zscore", "rank", "none"))

Arguments

scores

a score table (see [score_num()]) or a list of them

method

one of

`"range"`

min-max rescaling to \[0, 1\]. Bounded and easy to read, but a single extreme pair compresses everything else.

`"zscore"`

subtract the mean, divide by the standard deviation. Scale-free; unbounded, and the result can be negative (harmless – a constant shift is the same for every candidate).

`"rank"`

replace each score by its rank, rescaled to \[0, 1\] – that is, the empirical CDF of the score. Invariant to any monotone reparameterisation of the metric, so an edit distance and an unbounded L2 distance contribute equally regardless of their units. Ties share the average rank, so a heavily tied column spans less than the full \[0, 1\] and therefore counts for less – which is the right answer, since a column that puts many candidates on the same score discriminates between fewer of them.

`"none"`

leave the scores alone.

Value

an object of the same shape as `scores` (a single score table, or a list of them), with rescaled SCORE columns and unchanged `score_type`

Details

A column whose score never varies is mapped to constant 0 under every method: it cannot discriminate between candidates, so it must not shift the combined total either.

Examples

raw <- data.frame(ROW_NUMBER = 1:5, V = c(10, 20, 30, 40, 50), W = c(1, 1, 2, 2, 3))
d <- join_raw_anon_data(raw, raw)
s <- normalize_scores(list(score_num(d, "V"), score_num(d, "W")), method = "range")
match_greedy(combine_scores(s))
#>   ANON_ROW_NUMBER RAW_ROW_NUMBER CONFIDENCE RESULT
#> 1               1              1  0.3115885   TRUE
#> 2               2              2  0.3651484   TRUE
#> 3               3              3  0.5504819   TRUE
#> 4               4              4  0.4822428   TRUE
#> 5               5              5  0.9347654   TRUE