Description Usage Arguments Examples
To build krr model
1 | build_krr_model(K_train, y_train, gamma, set_b_0 = FALSE)
|
K_train |
|
y_train |
|
gamma |
|
set_b_0 |
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 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (K_train, y_train, gamma, set_b_0 = FALSE)
{
ntrain <- length(y_train)
if (set_b_0) {
if (rcond(K_train) < 1e-15)
return(NULL)
a <- solve(K_train + gamma * diag(ntrain), y_train)
b <- 0
}
else {
K1 <- K_train + gamma * diag(ntrain)
K2 <- cbind(K1, matrix(1, nrow = ntrain))
K3 <- rbind(K2, matrix(1, ncol = ntrain + 1))
K3[ntrain + 1, ntrain + 1] <- 0
if (rcond(K3) < 1e-15)
return(NULL)
y0 <- c(y_train, 0)
ab <- solve(K3, y0)
a <- ab[1:ntrain]
b <- ab[ntrain + 1]
}
list(a = a, b = b)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.