The qkernel Generalized Discriminant Analysis is a method that deals with nonlinear discriminant analysis using kernel function operator.
# S4 method for matrix
qkgda(x, label, kernel = "rbfbase", qpar = list(sigma = 0.1, q = 0.9),
features = 0, th = 1e-4, na.action = na.omit, ...)# S4 method for cndkernmatrix
qkgda(x, label, features = 0, th = 1e-4, na.action = na.omit, ...)
# S4 method for qkernmatrix
qkgda(x, label, features = 0, th = 1e-4, ...)
the data matrix indexed by row, or a kernel matrix of cndkernmatrix
or qkernmatrix
.
The original labels of the samples.
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
Power 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 Power 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 NA
s 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 eigenvectors and their normalized projections, along with the corresponding eigenvalues and the original function.
The normalized projections on eigenvectors)
The corresponding eigenvalues
The corresponding eigenvectors
The formula of the function called
The kernel function used
The original data matrix
all the slots of the object can be accessed by accessor functions.
The qkernel Generalized Discriminant Analysis method provides a mapping of the input vectors into high dimensional feature space, generalizing the classical Linear Discriminant Analysis to non-linear discriminant analysis.
The data can be passed to the qkgda
function in a matrix
, in addition qkgda
also supports input in the form of a
kernel matrix of class qkernmatrix
or class cndkernmatrix
.
1.Baudat, G, and F. Anouar: Generalized discriminant analysis using a kernel approach Neural Computation 12.10(2000),2385 2.Deng Cai, Xiaofei He, and Jiawei Han: Speed Up Kernel Discriminant Analysis The VLDB Journal,January,2011,vol.20, no.1,21-33.
# NOT RUN {
Iris <- data.frame(rbind(iris3[,,1], iris3[,,2], iris3[,,3]), Sp = rep(c("1","2","3"), rep(50,3)))
testset <- sample(1:150,20)
train <- as.matrix(iris[-testset,-5])
test <- as.matrix(iris[testset,-5])
Sp = rep(c("1","2","3"), rep(50,3))
labels <-as.numeric(Sp)
trainlabel <- labels[-testset]
testlabel <- labels[testset]
kgda1 <- qkgda(train, label=trainlabel, kernel = "ratibase", qpar = list(c=1,q=0.9),features = 2)
prj(kgda1)
eVal(kgda1)
eVec(kgda1)
kcall(kgda1)
# xmatrix(kgda1)
#print the principal component vectors
prj(kgda1)
#plot the data projection on the components
plot(kgda1@prj,col=as.integer(train), xlab="1st Principal Component",ylab="2nd Principal Component")
# }
Run the code above in your browser using DataLab