The Kernel Principal Components Analysis class

Objects of class "kpca"

Objects can be created by calls of the form new("kpca", ...). or by calling the kpca function.

Slots

pcv:

Object of class "matrix" containing the principal component vectors

eig:

Object of class "vector" containing the corresponding eigenvalues

rotated:

Object of class "matrix" containing the projection of the data on the principal components

kernelf:

Object of class "function" containing the kernel function used

kpar:

Object of class "list" containing the kernel parameters used

xmatrix:

Object of class "matrix" containing the data matrix used

kcall:

Object of class "ANY" containing the function call

n.action:

Object of class "ANY" containing the action performed on NA

Methods

eig

signature(object = "kpca"): returns the eigenvalues

kcall

signature(object = "kpca"): returns the performed call

kernelf

signature(object = "kpca"): returns the used kernel function

pcv

signature(object = "kpca"): returns the principal component vectors

predict

signature(object = "kpca"): embeds new data

rotated

signature(object = "kpca"): returns the projected data

xmatrix

signature(object = "kpca"): returns the used data matrix

Author

Alexandros Karatzoglou
alexandros.karatzoglou@ci.tuwien.ac.at

Examples

# another example using the iris
data(iris)
test <- sample(1:50,20)

kpc <- kpca(~.,data=iris[-test,-5],kernel="rbfdot",
            kpar=list(sigma=0.2),features=2)

#print the principal component vectors
pcv(kpc)
#>                [,1]         [,2]
#>   [1,] -0.307733687  0.065970840
#>   [2,] -0.299182287  0.051421702
#>   [3,] -0.296516213  0.051839701
#>   [4,] -0.307735361  0.071765233
#>   [5,] -0.302126303  0.069008638
#>   [6,] -0.282394780  0.060567487
#>   [7,] -0.301256785  0.048366210
#>   [8,] -0.296674830  0.057691698
#>   [9,] -0.304294693  0.046981125
#>  [10,] -0.297823308  0.058123877
#>  [11,] -0.268291982  0.087723131
#>  [12,] -0.290907373  0.077295049
#>  [13,] -0.273280850  0.030137707
#>  [14,] -0.301382807  0.063670137
#>  [15,] -0.302397316  0.055336614
#>  [16,] -0.294693572  0.107006869
#>  [17,] -0.295847369  0.024247867
#>  [18,] -0.303058010  0.031751141
#>  [19,] -0.299790777  0.041430860
#>  [20,] -0.298818628  0.034297631
#>  [21,] -0.296263604  0.035174508
#>  [22,] -0.287731658  0.080103117
#>  [23,] -0.274938448  0.083270319
#>  [24,] -0.304464739  0.076458706
#>  [25,] -0.306990276  0.077363323
#>  [26,] -0.306450897  0.051027710
#>  [27,] -0.308109798  0.073981838
#>  [28,] -0.297427888  0.027277536
#>  [29,] -0.284698552  0.010820524
#>  [30,] -0.297913002  0.049585366
#>  [31,]  0.112346232  0.037674090
#>  [32,]  0.114697803 -0.116204910
#>  [33,]  0.128002609  0.075661074
#>  [34,]  0.030533117 -0.367179927
#>  [35,]  0.124694016 -0.102608712
#>  [36,]  0.089645618 -0.279251387
#>  [37,]  0.125368255 -0.065534161
#>  [38,] -0.089488293 -0.325509364
#>  [39,]  0.116965836 -0.098399890
#>  [40,]  0.009447950 -0.367320175
#>  [41,] -0.058365196 -0.331794666
#>  [42,]  0.080990261 -0.275892594
#>  [43,]  0.036220529 -0.332652838
#>  [44,]  0.122139503 -0.160484235
#>  [45,] -0.010105542 -0.361513011
#>  [46,]  0.105166512 -0.097831715
#>  [47,]  0.090709008 -0.256333110
#>  [48,]  0.044303723 -0.347618571
#>  [49,]  0.100262785 -0.201026727
#>  [50,]  0.018312425 -0.378448467
#>  [51,]  0.124867823 -0.091951281
#>  [52,]  0.061229443 -0.305284559
#>  [53,]  0.130980457 -0.079988862
#>  [54,]  0.113049352 -0.186702086
#>  [55,]  0.096097379 -0.203172263
#>  [56,]  0.107516812 -0.126033156
#>  [57,]  0.125898350 -0.001747386
#>  [58,]  0.141301059  0.084914818
#>  [59,]  0.110453389 -0.213226122
#>  [60,] -0.030495743 -0.368875576
#>  [61,]  0.001733862 -0.383112494
#>  [62,] -0.014659646 -0.381938934
#>  [63,]  0.033540835 -0.359037360
#>  [64,]  0.135694335 -0.057061049
#>  [65,]  0.078083945 -0.271019396
#>  [66,]  0.102876773 -0.153704124
#>  [67,]  0.126189423 -0.015562410
#>  [68,]  0.092836146 -0.223193429
#>  [69,]  0.048022773 -0.334277830
#>  [70,]  0.033041698 -0.370661408
#>  [71,]  0.065305090 -0.327486453
#>  [72,]  0.115971353 -0.177348953
#>  [73,]  0.044373574 -0.355070498
#>  [74,] -0.083614444 -0.332073085
#>  [75,]  0.059429129 -0.341923126
#>  [76,]  0.058637049 -0.320683561
#>  [77,]  0.064457685 -0.322946753
#>  [78,]  0.092892439 -0.240147427
#>  [79,] -0.115131976 -0.304516668
#>  [80,]  0.055015620 -0.341453727
#>  [81,]  0.102005803  0.330500580
#>  [82,]  0.129979511 -0.049025986
#>  [83,]  0.109462526  0.393705881
#>  [84,]  0.140168338  0.175985601
#>  [85,]  0.127532565  0.305411322
#>  [86,]  0.045868941  0.446167437
#>  [87,]  0.044564078 -0.274631918
#>  [88,]  0.079544852  0.418072088
#>  [89,]  0.122108649  0.262721442
#>  [90,]  0.072414094  0.432236003
#>  [91,]  0.142601432  0.127633999
#>  [92,]  0.144939730  0.117059014
#>  [93,]  0.135277044  0.282297367
#>  [94,]  0.118194749 -0.085178885
#>  [95,]  0.119524442  0.029505863
#>  [96,]  0.135631794  0.196998222
#>  [97,]  0.143298485  0.195191262
#>  [98,]  0.021249275  0.417691083
#>  [99,]  0.018881695  0.408995354
#> [100,]  0.114650777 -0.114741589
#> [101,]  0.118526898  0.360425339
#> [102,]  0.115951176 -0.109735843
#> [103,]  0.035131606  0.427842238
#> [104,]  0.140756598 -0.028336661
#> [105,]  0.126730409  0.320870668
#> [106,]  0.099648890  0.395214595
#> [107,]  0.137296571 -0.069013171
#> [108,]  0.138478054 -0.046740133
#> [109,]  0.137390125  0.224521472
#> [110,]  0.108672904  0.336786348
#> [111,]  0.085182725  0.409914716
#> [112,]  0.026913048  0.409310693
#> [113,]  0.134909639  0.234953979
#> [114,]  0.141005227 -0.007584441
#> [115,]  0.125034595  0.067592349
#> [116,]  0.063027500  0.438514979
#> [117,]  0.119945082  0.262062973
#> [118,]  0.142533001  0.182043495
#> [119,]  0.131949991 -0.091653396
#> [120,]  0.133020190  0.279129512
#> [121,]  0.124867146  0.317630774
#> [122,]  0.128241101  0.225548855
#> [123,]  0.129979511 -0.049025986
#> [124,]  0.113083538  0.380100269
#> [125,]  0.113583088  0.346359998
#> [126,]  0.135530894  0.213789459
#> [127,]  0.137808132  0.002501059
#> [128,]  0.146097859  0.142475960
#> [129,]  0.126803836  0.193252177
#> [130,]  0.135756543 -0.027488423
rotated(kpc)
#>             [,1]        [,2]
#> 1   -10.70120706  1.17197151
#> 2   -10.40383859  0.91350618
#> 4   -10.31112786  0.92093192
#> 5   -10.70126528  1.27490885
#> 7   -10.50621450  1.22593797
#> 9    -9.82006567  1.07598098
#> 10  -10.47597767  0.85922538
#> 11  -10.31664364  1.02489260
#> 12  -10.58161863  0.83461936
#> 13  -10.35658109  1.03257027
#> 15   -9.32965149  1.55840080
#> 17  -10.11608468  1.37314601
#> 19   -9.50313563  0.53539616
#> 20  -10.48036000  1.13109953
#> 22  -10.51563878  0.98305456
#> 23  -10.24774688  1.90097628
#> 26  -10.28786931  0.43076318
#> 27  -10.53861393  0.56405879
#> 30  -10.42499834  0.73601894
#> 31  -10.39119261  0.60929717
#> 32  -10.30234358  0.62487488
#> 33  -10.00565159  1.42303132
#> 34   -9.56077734  1.47929662
#> 36  -10.58753188  1.35828838
#> 38  -10.67535549  1.37435889
#> 40  -10.65659902  0.90650691
#> 41  -10.71428605  1.31428683
#> 44  -10.34283066  0.48458524
#> 45   -9.90017761  0.19222653
#> 46  -10.35970013  0.88088368
#> 51    3.90675555  0.66927994
#> 52    3.98852966 -2.06437941
#> 53    4.45119428  1.34411846
#> 54    1.06176613 -6.52294883
#> 55    4.33614046 -1.82284305
#> 56    3.11735881 -4.96089893
#> 57    4.35958661 -1.16421391
#> 58   -3.11188797 -5.78267157
#> 59    4.06739879 -1.74807335
#> 60    0.32854534 -6.52544032
#> 61   -2.02960571 -5.89432990
#> 62    2.81637529 -4.90123000
#> 63    1.25954161 -5.90957533
#> 64    4.24730917 -2.85100131
#> 65   -0.35141259 -6.42227609
#> 66    3.65708619 -1.73797973
#> 67    3.15433739 -4.55375589
#> 68    1.54062857 -6.17544147
#> 69    3.48656281 -3.57123840
#> 70    0.63680078 -6.72313435
#> 71    4.34218444 -1.63351387
#> 72    2.12920774 -5.42337804
#> 73    4.55474669 -1.42100158
#> 74    3.93120604 -3.31676125
#> 75    3.34171395 -3.60935382
#> 76    3.73881613 -2.23897814
#> 77    4.37802025 -0.03104231
#> 78    4.91363785  1.50851115
#> 79    3.84093336 -3.78796056
#> 80   -1.06046648 -6.55307201
#> 81    0.06029374 -6.80599076
#> 82   -0.50977816 -6.78514248
#> 83    1.16635725 -6.37829617
#> 84    4.71866823 -1.01368913
#> 85    2.71531035 -4.81465766
#> 86    3.57746226 -2.73055267
#> 87    4.38814211 -0.27646611
#> 88    3.22830703 -3.96502969
#> 89    1.66995574 -5.93844329
#> 90    1.14900015 -6.58479731
#> 91    2.27093531 -5.81779454
#> 92    4.03281642 -3.15060290
#> 93    1.54305760 -6.30782489
#> 94   -2.90762929 -5.89927601
#> 95    2.06660316 -6.07426193
#> 96    2.03905920 -5.69694121
#> 97    2.24146741 -5.73714680
#> 98    3.23026455 -4.26621735
#> 99   -4.00362771 -5.40973647
#> 100   1.91312673 -6.06592306
#> 101   3.54717492  5.87134047
#> 102   4.51993954 -0.87094629
#> 103   3.80647687  6.99418220
#> 104   4.87424831  3.12638297
#> 105   4.43484884  5.42562999
#> 106   1.59505784  7.92616138
#> 107   1.54968224 -4.87883410
#> 108   2.76611229  7.42704771
#> 109   4.24623626  4.66724456
#> 110   2.51814556  7.67866955
#> 111   4.95885734  2.26741710
#> 112   5.04016990  2.07955257
#> 113   4.70415725  5.01501074
#> 114   4.11013332 -1.51320229
#> 115   4.15637241  0.52417145
#> 116   4.71649344  3.49967203
#> 117   4.98309683  3.46757141
#> 118   0.73892752  7.42027916
#> 119   0.65659672  7.26579959
#> 120   3.98689437 -2.03838352
#> 121   4.12168357  6.40295361
#> 122   4.03211477 -1.94945648
#> 123   1.22167512  7.60061434
#> 124   4.89470462 -0.50340058
#> 125   4.40695446  5.70026516
#> 126   3.46521507  7.02098449
#> 127   4.77438478 -1.22601851
#> 128   4.81546998 -0.83033814
#> 129   4.77763805  3.98862236
#> 130   3.77901836  5.98300710
#> 131   2.96216508  7.28213204
#> 132   0.93588098  7.27140158
#> 133   4.69138104  4.17395579
#> 134   4.90335051 -0.13473755
#> 135   4.34798383  1.20077760
#> 136   2.19173382  7.79021552
#> 137   4.17099982  4.65554687
#> 138   4.95647769  3.23400140
#> 139   4.58846151 -1.62822194
#> 140   4.62567687  4.95873382
#> 141   4.34216091  5.64270847
#> 142   4.45948764  4.00687383
#> 143   4.51993954 -0.87094629
#> 144   3.93239482  6.75247860
#> 145   3.94976629  6.15308292
#> 146   4.71298471  3.79796823
#> 147   4.79217393  0.04443129
#> 148   5.08044296  2.53108442
#> 149   4.40950783  3.43312356
#> 150   4.72083146 -0.48833164
kernelf(kpc)
#> new("rbfkernel", .Data = function (x, y = NULL) 
#> {
#>     if (!is(x, "vector")) 
#>         stop("x must be a vector")
#>     if (!is(y, "vector") && !is.null(y)) 
#>         stop("y must a vector")
#>     if (is(x, "vector") && is.null(y)) {
#>         return(1)
#>     }
#>     if (is(x, "vector") && is(y, "vector")) {
#>         if (!length(x) == length(y)) 
#>             stop("number of dimension must be the same on both data points")
#>         return(exp(sigma * (2 * crossprod(x, y) - crossprod(x) - 
#>             crossprod(y))))
#>     }
#> }, kpar = list(sigma = 0.2))
#> <bytecode: 0x564204d155f8>
#> <environment: 0x564207ed5290>
#> attr(,"kpar")
#> attr(,"kpar")$sigma
#> [1] 0.2
#> 
#> attr(,"class")
#> [1] "rbfkernel"
#> attr(,"class")attr(,"package")
#> [1] "kernlab"
eig(kpc)
#>    Comp.1    Comp.2 
#> 0.2674942 0.1366538