kernelMatrix
stringdot
, , .
x
kernelMatrix
, :
if (is(x, "list"))
x <- sapply(x, paste, collapse = "")
, lst
c("123", "321")
.
kernelMatrix
( sk
- stringkernel):
sk("123", "123") sk("123", "321")
sk("321", "321")
, , .
, :
stringdot(type = "exponential", lambda = 1.2)(123, 321)
, length
type = "exponential"
. stringkernel
, exponential
it lambda
, . , , lambda
- .
stringdot(type = "spectrum")
, , length
, , . 123
321
>= 2 , .
, ("\n"
) > 0 type = "exponential"
, , .
stringdot(type = "exponential", lambda = 1.2)("blowfish", "mage")
, , @Rahul R Lodhi 2002. kernlab
, R-, . , python github, , , . , -, python R, /.
:
stringkernel , .
sk_u <- stringdot(type = "exponential", lambda = 1.2, normalized = FALSE)
sk_n <- stringdot(type = "exponential", lambda = 1.2, normalized = TRUE)
lapply(list(unnormalised = sk_u, normalised = sk_n), function(f) {
c(
"ab,xyzabqr" = f("ab", "xyzabqr"),
"ab,abpmnop" = f("ab", "abpmnop"),
"ab,ab" = f("ab"),
"xyzabqr,xyzabqr" = f("xyzabqr"),
"abpmnop,abpmnop" = f("abpmnop")
)
})
, , . , (,) sk_u("ab", "xyzabqr") / sqrt(sk_u("ab") * sk_u("xyzabqr"))
, , sk_n("ab", "xyzabqr")
, , "abpmnop"
p.