csi-class.RdThe reduced Cholesky decomposition object
Objects can be created by calls of the form new("csi", ...).
or by calling the csi function.
.Data:Object of class "matrix" contains
the decomposed matrix
pivots:Object of class "vector" contains
the pivots performed
diagresidues:Object of class "vector" contains
the diagonial residues
maxresiduals:Object of class "vector" contains
the maximum residues
Object of class "vector" contains
the predicted gain before adding each column
Object of class "vector" contains
the actual gain after adding each column
Object of class "matrix" contains
Q from the QR decomposition of the kernel matrix
Object of class "matrix" contains
R from the QR decomposition of the kernel matrix
Class "matrix", directly.
signature(object = "csi"): returns
the diagonial residues
signature(object = "csi"): returns
the maximum residues
signature(object = "csi"): returns
the pivots performed
signature(object = "csi"): returns
the predicted gain before adding each column
signature(object = "csi"): returns
the actual gain after adding each column
signature(object = "csi"): returns
Q from the QR decomposition of the kernel matrix
signature(object = "csi"): returns
R from the QR decomposition of the kernel matrix
data(iris)
## create multidimensional y matrix
yind <- t(matrix(1:3,3,150))
ymat <- matrix(0, 150, 3)
ymat[yind==as.integer(iris[,5])] <- 1
datamatrix <- as.matrix(iris[,-5])
# initialize kernel function
rbf <- rbfdot(sigma=0.1)
rbf
#> 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.1))
#> <bytecode: 0x564204d155f8>
#> <environment: 0x564204d17ac8>
#> attr(,"kpar")
#> attr(,"kpar")$sigma
#> [1] 0.1
#>
#> attr(,"class")
#> [1] "rbfkernel"
#> attr(,"class")attr(,"package")
#> [1] "kernlab"
Z <- csi(datamatrix,ymat, kernel=rbf, rank = 30)
dim(Z)
#> [1] 150 30
pivots(Z)
#> [1] 1 101 132 119 106 80 66 135 57 74 122 111 58 11 39 33 54 86
#> [19] 44 136 62 85 35 142 27 91 115 109 77 138 99 53 46 67 123 146
#> [37] 61 149 120 108 10 17 130 9 52 70 107 118 114 141 19 127 104 82
#> [55] 100 110 131 51 140 5 21 126 40 105 12 64 22 28 34 6 71 72
#> [73] 73 56 75 76 48 78 79 2 81 14 83 84 49 8 87 88 89 90
#> [91] 43 92 93 94 95 96 97 98 23 15 18 102 103 20 24 13 3 37
#> [109] 45 42 25 112 113 59 38 116 117 41 4 30 121 69 50 124 125 68
#> [127] 60 128 129 55 63 31 133 134 32 7 137 16 139 65 29 36 143 144
#> [145] 145 26 147 148 47 150
# calculate kernel matrix
K <- crossprod(t(Z))
# difference between approximated and real kernel matrix
(K - kernelMatrix(kernel=rbf, datamatrix))[6,]
#> [1] 0.000000e+00 3.294318e-03 1.644680e-03 1.608380e-03 -1.220268e-03
#> [6] -6.078501e-03 9.589439e-05 8.384188e-04 9.656466e-04 2.836263e-03
#> [11] -2.930943e-03 4.098783e-04 2.980274e-03 -2.220446e-16 -8.965374e-03
#> [16] -1.653778e-02 -5.867396e-03 1.008349e-05 -5.410934e-03 -3.900733e-03
#> [21] 6.643020e-04 -2.409574e-03 -1.998123e-03 1.475035e-03 0.000000e+00
#> [26] 3.350540e-03 7.407855e-04 -8.013015e-05 1.165805e-03 1.477897e-03
#> [31] 2.283301e-03 9.742738e-04 -9.253187e-03 -1.203781e-02 2.748481e-03
#> [36] 2.719135e-03 8.271673e-05 -1.322824e-03 8.292507e-04 9.523782e-04
#> [41] 1.221245e-15 0.000000e+00 3.044012e-04 1.443290e-15 -4.048128e-03
#> [46] 2.787433e-03 -4.075572e-03 1.232110e-03 -2.788301e-03 1.824274e-03
#> [51] 0.000000e+00 5.920832e-05 3.994131e-05 -7.013161e-05 5.777698e-06
#> [56] 8.783444e-05 6.449669e-05 -3.406535e-05 2.778523e-06 7.216450e-16
#> [61] 5.551115e-16 1.994334e-05 -2.210526e-04 4.522136e-05 0.000000e+00
#> [66] 4.046290e-05 -1.665335e-16 -5.551115e-17 -3.510309e-04 6.106227e-16
#> [71] -7.302072e-05 -4.572073e-05 -1.375647e-04 6.587981e-05 -6.804974e-06
#> [76] 5.241305e-05 -3.462390e-05 3.640250e-05 1.404683e-05 1.110223e-16
#> [81] -2.034306e-05 -1.110223e-16 -5.068559e-05 -4.275164e-05 -1.662684e-05
#> [86] -5.551115e-17 7.944239e-05 -2.804399e-04 -9.909627e-06 -2.937080e-05
#> [91] 2.234118e-04 4.748586e-05 -5.556823e-05 -1.193880e-04 3.728456e-05
#> [96] -2.273134e-05 1.539013e-05 -5.502633e-06 2.220446e-16 1.110223e-16
#> [101] -4.163336e-17 -3.465849e-04 3.059177e-05 -2.498002e-16 5.551115e-17
#> [106] -6.938894e-18 -5.551115e-17 -3.659936e-05 -8.564319e-05 9.177555e-05
#> [111] 2.220446e-16 -1.817270e-04 -2.694895e-05 -5.026887e-04 -8.584143e-04
#> [116] -1.605942e-04 -1.421009e-05 -2.210191e-04 1.040834e-17 -5.551115e-17
#> [121] 5.023864e-05 -5.314147e-04 -2.145284e-04 -1.636829e-04 -8.908144e-06
#> [126] -7.560976e-05 -1.240224e-04 -8.208677e-05 -1.398680e-04 -1.672290e-04
#> [131] -1.861385e-04 -6.403198e-04 -1.693464e-04 3.200999e-06 2.846070e-04
#> [136] -1.526557e-16 -2.339729e-04 2.775558e-17 -9.652743e-05 1.424119e-05
#> [141] -1.665335e-16 1.770770e-04 -3.465849e-04 1.062464e-04 2.549706e-05
#> [146] -2.220446e-16 -3.128903e-04 -7.610019e-05 -2.763565e-04 -1.687860e-04