minor. rename gausskernel fnc
This commit is contained in:
parent
38d8f0a401
commit
104fc0c95c
|
@ -1,6 +1,6 @@
|
||||||
# compute the gaussian kernel between each row of X1 and each row of X2
|
# compute the gaussian kernel between each row of X1 and each row of X2
|
||||||
# should be done more efficiently
|
# should be done more efficiently
|
||||||
gausskernel <-
|
gausskernel.nakr <-
|
||||||
function(X1, X2, sigma2)
|
function(X1, X2, sigma2)
|
||||||
{
|
{
|
||||||
n1 <- dim(X1)[1]
|
n1 <- dim(X1)[1]
|
||||||
|
@ -34,7 +34,7 @@ function(X, y, sigma2=NULL, lambda=1E-4, landmarks=NULL, nb.landmarks=NULL)
|
||||||
X <- scale(X)
|
X <- scale(X)
|
||||||
y <- scale(y)
|
y <- scale(y)
|
||||||
|
|
||||||
C <- gausskernel(X, as.matrix(X[splidx,]), sigma2)
|
C <- gausskernel.nakr(X, as.matrix(X[splidx,]), sigma2)
|
||||||
K11 <- C[splidx,]
|
K11 <- C[splidx,]
|
||||||
|
|
||||||
svdK11 <- svd(K11)
|
svdK11 <- svd(K11)
|
||||||
|
@ -80,7 +80,7 @@ function(o, newdata)
|
||||||
}
|
}
|
||||||
newdata <- scale(newdata,center=attr(o$X,"scaled:center"),
|
newdata <- scale(newdata,center=attr(o$X,"scaled:center"),
|
||||||
scale=attr(o$X,"scaled:scale"))
|
scale=attr(o$X,"scaled:scale"))
|
||||||
Ktest <- gausskernel(newdata, as.matrix(o$X[o$splidx,]), o$sigma2)
|
Ktest <- gausskernel.nakr(newdata, as.matrix(o$X[o$splidx,]), o$sigma2)
|
||||||
yh <- Ktest %*% o$beta
|
yh <- Ktest %*% o$beta
|
||||||
yh <- (yh * attr(o$y,"scaled:scale")) + attr(o$y,"scaled:center")
|
yh <- (yh * attr(o$y,"scaled:scale")) + attr(o$y,"scaled:center")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue