Inject domain knowledge into the credibility matrix by rewarding pairs that
should share a cluster (must_link()) or severing pairs that should not
(cannot_link()), following Delias et al. (2023).
Arguments
- sim
An
outrank_simobject fromoutrank_similarity().- pairs_or_attribute
A two-column matrix of case-id pairs, or a length-one attribute name (requires that
simcarries case attributes).- reward
Positive amount added to
Sfor each must-linked pair.
Details
With a symmetric 0/1 constraint mask M (zero diagonal),
$$\text{must\_link:}\quad S \leftarrow \min(S + \text{reward}\cdot M,\ 1),$$
$$\text{cannot\_link:}\quad S \leftarrow S \odot (1 - M).$$
The constraint set is given either as a two-column matrix of case-id pairs,
or as the name of a case attribute: must_link() then links cases with an
equal attribute value, and cannot_link() severs cases whose values differ.
Examples
m <- matrix(0.2, 4, 4); diag(m) <- 1; dimnames(m) <- list(1:4, 1:4)
crit <- criterion(m, "similarity", indifference = 0.1, similarity = 0.9)
tr <- as_traces(data.frame(case = as.character(1:4), act = "x",
ts = as.POSIXct("2020-01-01")),
"case", "act", "ts")
sim <- outrank_similarity(tr, crit)
sim <- must_link(sim, cbind("1", "2"))
cannot_link(sim, cbind("3", "4"))$S
#> 1 2 3 4
#> 1 1.000 1.000 0.125 0.125
#> 2 1.000 1.000 0.125 0.125
#> 3 0.125 0.125 1.000 0.000
#> 4 0.125 0.125 0.000 1.000