Description Usage Arguments Value Note Author(s) References See Also Examples
Calculates all of the Kendall's distances between two sets of total rankings or real-valued vectors.
1 2 |
r |
A vector or a matrix of |
seqs |
Another vector or a matrix of |
data.info |
Optional argument giving the Kendall embedding of " |
use.kernel.trick |
Logical. Indicator of whether the kernel trick is explored.
This is particularly interesting when the number of items to be ranked is large |
kmat |
Kendall kernel matrix of dimension |
type |
A character string indicating the type of Kendall correlation for " |
mc |
A normalization constant default to 0.25 such that output normalized squared Euclidean distance in the feature space induced by Kendall embedding amounts exactly to Kendall distances. |
A matrix of dimension m1 x m2
where entry [i,j]
is the distance from sequence i
in "r
" to sequence j
in "seqs
".
Kernel trick is explored in the sense that "r
" and "seq
" are only used for checking dimensions and getting attributes but not used explicitly to compute the distance.
Option "use.kernel.trick
" set TRUE
or FALSE
may give slightly different results due to computation precision of two implementations.
Yunlong Jiao
Kendall's tau rank correlation coefficient: https://en.wikipedia.org/wiki/Kendall_rank_correlation_coefficient
Yunlong Jiao, Jean-Philippe Vert. "The Kendall and Mallows Kernels for Permutations." IEEE Transactions on Pattern Analysis and Machine Intelligence (TPAMI), vol. 40, no. 7, pp. 1755-1769, 2018. DOI:10.1109/TPAMI.2017.2719680
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #### Ex 1: Compute Kendall distance matrix and Mallows kernel matrix
data1 <- do.call("rbind", list(1:5, 5:1, c(3, 2, 1, 4, 5)))
data2 <- do.call("rbind", list(1:5, 5:1))
# Kendall distance matrix
s.K.d.mat <- AllKendall(data1, data2)
# Mallows kernel matrix with dispersion parameter lambda
lambda <- 0.1
M.k.kmat <- exp(-lambda * s.K.d.mat)
#### Ex 2: Why kernel trick?
r <- lapply(1:20, function(i) sample.int(1000, replace = TRUE))
r <- do.call('rbind', r)
dim(r)
# I) Without kernel trick
pt <- proc.time()
dmat1 <- AllKendall(r, use.kernel.trick = FALSE)
proc.time() - pt
# II) With kernel trick (should be much faster in this setting)
require(pcaPP)
pt <- proc.time()
dmat2 <- AllKendall(r, use.kernel.trick = TRUE)
proc.time() - pt
# NOTE: dmat1 and dmat2 may return slightly different values due to computation precision
isTRUE(all.equal(dmat1, dmat2, check.attributes = FALSE)) # May sometimes output FALSE
isTRUE(max(abs(dmat1 - dmat2)) < 1e-6) # Should always output TRUE
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.