qkpca: qKernel Principal Components Analysis

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

The qkernel Principal Components Analysis is a nonlinear form of principal component analysis.

Usage

1
2
3
4
5
6
7
8
9
## S4 method for signature 'formula'
qkpca(x, data = NULL, na.action, ...)
## S4 method for signature '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 signature 'cndkernmatrix'
qkpca(x, features = 0, th = 1e-4, ...)
## S4 method for signature 'qkernmatrix'
qkpca(x, features = 0, th = 1e-4, ...)

Arguments

x

the data matrix indexed by row, a formula describing the model or a kernel matrix of cndkernmatrix or qkernmatrix.

data

an optional data frame containing the variables in the model (when using a formula).

kernel

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.

qpar

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.

features

Number of features (principal components) to return. (default: 0 , all)

th

the value of the eigenvalue under which principal components are ignored (only valid when features = 0). (default : 0.0001)

na.action

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

Details

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.

Value

An S4 object containing the principal component vectors along with the corresponding eigenvalues.

pcv

a matrix containing the principal component vectors (column wise)

eVal

The corresponding eigenvalues

rotated

The original data projected (rotated) on the principal components

cndkernf

the kernel function used

xmatrix

The original data matrix

all the slots of the object can be accessed by accessor functions.

Note

The predict function can be used to embed new data on the new space

Author(s)

Yusen Zhang
yusenzhang@126.com

References

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

See Also

qkernmatrix, cndkernmatrix

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# 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]))

Example output

               [,1]         [,2]
  [1,]  0.274028336  0.507609993
  [2,]  0.293050766 -0.185892003
  [3,]  0.278785574 -0.489400451
  [4,]  0.234681453  1.120848492
  [5,]  0.286639021 -0.114345988
  [6,]  0.268163766  0.248799934
  [7,]  0.291590277 -0.862926457
  [8,]  0.272072858 -0.180640607
  [9,]  0.256945088  0.997124902
 [10,]  0.266662741  0.006406207
 [11,]  0.282772606 -0.347738345
 [12,]  0.323802681 -0.684153964
 [13,]  0.270279609  1.871927611
 [14,]  0.245061354  2.085746020
 [15,]  0.268416842  1.286346219
 [16,]  0.270504661  0.493767172
 [17,]  0.264920319  0.797573889
 [18,]  0.237098329  0.566413080
 [19,]  0.260449096  0.668349577
 [20,]  0.324677916  0.315640369
 [21,]  0.236004481  0.106676613
 [22,]  0.241201528 -0.123425193
 [23,]  0.255625105 -0.254889370
 [24,]  0.252630852  0.177708836
 [25,]  0.269555185  0.492229112
 [26,]  0.263608355 -0.338704040
 [27,]  0.246939633  0.623964068
 [28,]  0.271046105  1.272218870
 [29,]  0.266112860  1.717593558
 [30,]  0.268570575 -0.195283854
 [31,]  0.291096684  0.153523820
 [32,]  0.268243715  0.952085620
 [33,]  0.285373629  0.438884203
 [34,]  0.300898683 -0.702204960
 [35,]  0.264677968  0.348567902
 [36,]  0.282302887  0.438513929
 [37,]  0.302986641 -0.474754479
 [38,]  0.246398563  0.267299779
 [39,]  0.227341309  0.617423163
 [40,]  0.275777817 -0.377298973
 [41,]  0.260039959  0.768491477
 [42,]  0.288135697 -0.329127212
 [43,]  0.260501833  0.896137619
 [44,]  0.275535127  0.177901392
 [45,] -0.135468642  1.068307648
 [46,] -0.099948065  0.420047738
 [47,] -0.154093647  0.800429923
 [48,] -0.023459375 -1.488087923
 [49,] -0.116499540  0.055823028
 [50,] -0.070602312 -0.815270009
 [51,]  0.074049056 -1.793097972
 [52,] -0.111668954  0.292629028
 [53,] -0.002957000 -1.340381721
 [54,]  0.048174675 -2.197408269
 [55,] -0.031771614 -1.029559722
 [56,] -0.105942079 -0.298404692
 [57,]  0.014948062 -0.588845334
 [58,] -0.099313926  0.670815755
 [59,] -0.072339136 -0.707057145
 [60,] -0.102441332 -0.942092844
 [61,] -0.008634714 -1.114161371
 [62,] -0.119126970 -0.213820249
 [63,] -0.040806066 -0.256067550
 [64,] -0.138417294 -0.564533324
 [65,] -0.099439923 -0.402731967
 [66,] -0.077748548  0.127278695
 [67,] -0.096704017  0.442414051
 [68,] -0.141129388  0.366218321
 [69,]  0.028475785 -0.773330595
 [70,]  0.003067636 -1.310229632
 [71,]  0.015847611 -1.275236038
 [72,] -0.017855719 -0.673035415
 [73,] -0.146634387 -0.714772579
 [74,] -0.064834641 -0.927246828
 [75,] -0.086828459  0.195771536
 [76,] -0.129509460  0.607406010
 [77,] -0.088862041 -0.688273098
 [78,] -0.029041920 -0.604869811
 [79,] -0.021441380 -1.262355897
 [80,] -0.052445915 -1.236432880
 [81,] -0.096089181 -0.164400136
 [82,]  0.069291988 -1.801501029
 [83,] -0.037978526 -0.512414539
 [84,] -0.042791940 -0.633837191
 [85,] -0.070366823 -0.098427471
 [86,] -0.034848709 -0.724926348
 [87,] -0.258721176  0.185324461
 [88,] -0.150206023 -0.946988384
 [89,] -0.242285608  0.095514751
 [90,] -0.058484344 -2.043518879
 [91,] -0.296363237  0.865062618
 [92,] -0.239836443 -0.226790632
 [93,] -0.293710119  1.535368567
 [94,] -0.174338444  0.410108531
 [95,] -0.189212434 -0.295295636
 [96,] -0.224348031  0.472404895
 [97,] -0.167083699 -0.838660116
 [98,] -0.198458158  0.263261391
 [99,] -0.203273012  0.131875272
[100,] -0.372485922  0.983821449
[101,] -0.138878792 -1.254400488
[102,] -0.249224530  0.787303715
[103,] -0.128066078 -1.027431830
[104,] -0.346665163  1.196810221
[105,] -0.147547280 -0.348468431
[106,] -0.234515386  0.670717348
[107,] -0.266421153  1.104618760
[108,] -0.134208651 -0.332058495
[109,] -0.137300286 -0.235069352
[110,] -0.220648491 -0.221193588
[111,] -0.245089911  0.905596945
[112,] -0.288095501  0.885682582
[113,] -0.319763998  2.521363071
[114,] -0.224122883 -0.221327788
[115,] -0.152943570 -0.258592217
[116,] -0.186672982 -0.774803815
[117,] -0.308915839  1.450223116
[118,] -0.221488132  0.337113608
[119,] -0.198729784  0.130239200
[120,] -0.124871253 -0.330444460
[121,] -0.218418495  0.711756461
[122,] -0.238552639  0.457057273
[123,] -0.200014932  0.750294662
[124,] -0.150206023 -0.946988384
[125,] -0.262169974  0.652553614
[126,] -0.248134027  0.669899096
[127,] -0.202559127  0.394357828
[128,] -0.161718738 -0.590920832
[129,] -0.184934970  0.168659289
[130,] -0.147336415 -0.493355082

qkerntool documentation built on May 2, 2019, 6:11 a.m.