do.kpca | R Documentation |
Kernel principal component analysis (KPCA/Kernel PCA) is a nonlinear extension of classical PCA using techniques called kernel trick, a common method of introducing nonlinearity by transforming, usually, covariance structure or other gram-type estimate to make it flexible in Reproducing Kernel Hilbert Space.
do.kpca( X, ndim = 2, preprocess = c("null", "center", "scale", "cscale", "whiten", "decorrelate"), kernel = c("gaussian", 1) )
X |
an (n\times p) matrix or data frame whose rows are observations and columns represent independent variables. |
ndim |
an integer-valued target dimension. |
preprocess |
an additional option for preprocessing the data.
Default is "null". See also |
kernel |
a vector containing name of a kernel and corresponding parameters. See also |
a named list containing
an (n\times ndim) matrix whose rows are embedded observations.
a list containing information for out-of-sample prediction.
variances of projected data / eigenvalues from kernelized covariance matrix.
Kisung You
scholkopf_kernel_1997Rdimtools
aux.kernelcov
## load iris data data(iris) set.seed(100) subid = sample(1:150,50) X = as.matrix(iris[subid,1:4]) label = as.factor(iris[subid,5]) ## try out different settings output1 <- do.kpca(X) # default setting output2 <- do.kpca(X,kernel=c("gaussian",5)) # gaussian kernel with large bandwidth output3 <- do.kpca(X,kernel=c("laplacian",1)) # laplacian kernel ## visualize three different projections opar <- par(no.readonly=TRUE) par(mfrow=c(1,3)) plot(output1$Y, col=label, pch=19, main="Gaussian kernel") plot(output2$Y, col=label, pch=19, main="Gaussian kernel with sigma=5") plot(output3$Y, col=label, pch=19, main="Laplacian kernel") par(opar)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.