The qkernel Principal Components Analysis is a nonlinear form of principal component analysis.
# S4 method for formula
qkpca(x, data = NULL, na.action, ...)
# S4 method for matrix
qkpca(x, kernel = "rbfbase", qpar = list(sigma = 0.1, q = 0.9),
features = 0, th = 1e-4, na.action = na.omit, ...)
# S4 method for cndkernmatrix
qkpca(x, features = 0, th = 1e-4, ...)
# S4 method for qkernmatrix
qkpca(x, features = 0, th = 1e-4, ...)the data matrix indexed by row, a formula describing the
model or a kernel matrix of cndkernmatrix or qkernmatrix.
an optional data frame containing the variables in the model (when using a formula).
the kernel function used in training and predicting. This parameter can be set to any function, of class kernel, which computes a kernel function value between two vector arguments. qkerntool provides the most popular kernel functions which can be used by setting the kernel parameter to the following strings:
rbfbase Radial Basis qkernel function "Gaussian"
nonlbase Non Linear qkernel function
laplbase Laplbase qkernel function
ratibase Rational Quadratic qkernel function
multbase Multiquadric qkernel function
invbase Inverse Multiquadric qkernel function
wavbase Wave qkernel function
powbase d qkernel function
logbase Log qkernel function
caubase Cauchy qkernel function
chibase Chi-Square qkernel function
studbase Generalized T-Student qkernel function
nonlcnd Non Linear cndkernel function
polycnd Polynomial cndkernel function
rbfcnd Radial Basis cndkernel function "Gaussian"
laplcnd Laplacian cndkernel function
anocnd ANOVA cndkernel function
raticnd Rational Quadratic cndkernel function
multcnd Multiquadric cndkernel function
invcnd Inverse Multiquadric cndkernel function
wavcnd Wave cndkernel function
powcnd power cndkernel function
logcnd Log cndkernel function
caucnd Cauchy cndkernel function
chicnd Chi-Square cndkernel function
studcnd Generalized T-Student cndkernel function
The kernel parameter can also be set to a user defined function of class kernel by passing the function name as an argument.
the list of hyper-parameters (kernel parameters). This is a list which contains the parameters to be used with the kernel function. Valid parameters for existing kernels are :
sigma, q for the Radial Basis qkernel function "rbfbase" , the Laplacian qkernel function "laplbase" and the Cauchy qkernel function "caubase".
alpha, q for the Non Linear qkernel function "nonlbase".
c, q for the Rational Quadratic qkernel function "ratibase" , the Multiquadric qkernel function "multbase" and the Inverse Multiquadric qkernel function "invbase".
theta, q for the Wave qkernel function "wavbase".
d, q for the d qkernel function "powbase" , the Log qkernel function "logbase" and the Generalized T-Student qkernel function "studbase".
alpha for the Non Linear cndkernel function "nonlcnd".
d, alpha, c for the Polynomial cndkernel function "polycnd".
gamma for the Radial Basis cndkernel function "rbfcnd" and the Laplacian cndkernel function "laplcnd" and the Cauchy cndkernel function "caucnd".
d, sigma for the ANOVA cndkernel function "anocnd".
c for the Rational Quadratic cndkernel function "raticnd" , the Multiquadric cndkernel function "multcnd" and the Inverse Multiquadric cndkernel function "invcnd".
theta for the Wave cndkernel function "wavcnd".
d for the power cndkernel function "powcnd" , the Log cndkernel function "logcnd" and the Generalized T-Student cndkernel function "studcnd".
Hyper-parameters for user defined kernels can be passed through the qpar parameter as well.
Number of features (principal components) to return. (default: 0 , all)
the value of the eigenvalue under which principal components are ignored (only valid when features = 0). (default : 0.0001)
A function to specify the action to be taken if NAs are
found. The default action is na.omit, which leads to rejection of cases
with missing values on any required variable. An alternative
is na.fail, which causes an error if NA cases
are found. (NOTE: If given, this argument must be named.)
additional parameters
An S4 object containing the principal component vectors along with the corresponding eigenvalues.
a matrix containing the principal component vectors (column wise)
The corresponding eigenvalues
The original data projected (rotated) on the principal components
the kernel function used
The original data matrix
all the slots of the object can be accessed by accessor functions.
Using kernel functions one can efficiently compute
principal components in high-dimensional
feature spaces, related to input space by some non-linear map.
The data can be passed to the qkpca function in a matrix, in addition qkpca also supports input in the form of a
kernel matrix of class qkernmatrix or class cndkernmatrix.
Schoelkopf B., A. Smola, K.-R. Mueller : Nonlinear component analysis as a kernel eigenvalue problem Neural Computation 10, 1299-1319 http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.29.1366
# NOT RUN {
# another example using the iris data
data(iris)
test <- sample(1:150,20)
qkpc <- qkpca(~.,data=iris[-test,-5],kernel="rbfbase",
qpar=list(sigma=50,q=0.8),features=2)
# print the principal component vectors
pcv(qkpc)
#plot the data projection on the components
plot(rotated(qkpc),col=as.integer(iris[-test,5]),
xlab="1st Principal Component",ylab="2nd Principal Component")
# embed remaining points
emb <- predict(qkpc,iris[test,-5])
points(emb,col=as.integer(iris[test,5]))
# }
Run the code above in your browser using DataLab