| Title: | Kernel Independent Component Analysis |
|---|---|
| Description: | The kernel independent component analysis (kernel ICA) method introduced by Bach and Jordan (2002) <doi:10.1162/153244303768966085>. A separate function for the incomplete Cholesky decomposition used in kernel ICA is also provided. |
| Authors: | Christoph L. Koesner [aut] (ORCID: <https://orcid.org/0000-0002-2061-8022>), Juho Eagling [aut] (ORCID: <https://orcid.org/0000-0001-8333-5057>), Klaus Nordhausen [aut, cre] (ORCID: <https://orcid.org/0000-0002-3758-8501>) |
| Maintainer: | Klaus Nordhausen <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 2.0.0 |
| Built: | 2026-10-13 11:56:10 UTC |
| Source: | https://github.com/cran/KernelICA |
The kernel independent component analysis (kernel ICA) method introduced by Bach and Jordan in 2002 (see references). A separate function for the incomplete Cholesky decomposition used in kernel ICA is also provided.
Maintainer: Klaus Nordhausen [email protected] (ORCID)
Authors:
Klaus Nordhausen [email protected] (ORCID)
Christoph L. Koesner [email protected] (ORCID)
Juho Eagling [email protected] (ORCID)
Francis R. Bach, Michael I. Jordan
Kernel independent component analysis
Journal of Machine Learning Research 2002
doi:10.1162/153244303768966085
Francis R. Bach, Michael I. Jordan
Predictive low-rank decomposition for kernel methods.
Proceedings of the Twenty-second International Conference on Machine Learning (ICML) 2005
doi:10.1145/1102351.1102356.
Sean Martin, Andrew M. Raim, Wen Huang, Kofi P. Adragni
ManifoldOptim: An R Interface to the ROPTLIB Library for Riemannian Manifold Optimization
Journal of Statistical Software 2020
doi:10.18637/jss.v093.i01
The incomplete Cholesky decomposition, which computes approximative low rank decompositions for either Gauss or Hermite kernel matrices. Its implementation is inspired by Matlab and C code of F. Bach (see references) and written with the C++ library Eigen3 for speed purposes.
incomplete_cholesky( x, kernel = c("gauss", "hermite"), eps = 1e-04, sigma = ifelse(length(x) < 1000, 1, 0.5), hermite_rank = 3 )incomplete_cholesky( x, kernel = c("gauss", "hermite"), eps = 1e-04, sigma = ifelse(length(x) < 1000, 1, 0.5), hermite_rank = 3 )
x |
Numeric vector. |
kernel |
One of |
eps |
Numeric precision parameter for the matrix approximation. |
sigma |
Numeric value, setting the kernel variance. Default is 1 for vectors smaller than n=1000, otherwise 0.5. |
hermite_rank |
Integer value for the rank of the Hermite kernel. This parameter is ignored, when the Gaussian kernel is chosen. Default is 3. |
The function approximates kernel matrices of the form
for a vector and a kernel function .
It returns a permutation matrix given as index vector and
a numeric matrix which is a "cut off" lower triangle matrix,
as it contains only the first columns that were necessary to attain a sufficient approximation.
These matrices follow the inequality
where is the given precision parameter. The function offers approximation for kernel matrices of the following two kernels:
Gauss Kernel (fix v1.0.1: corrected sign in exponent):
Hermite Kernel: ,
where is the Hermite polynomial of grade
A list containing the following entries:
A numeric matrix which values are for .
An integer vector of indices representing the permutation matrix.
Kernel ICA implementation in Matlab and C by F. Bach containing the Incomplete Cholesky Decomposition:
https://www.di.ens.fr/~fbach/kernel-ica/index.htm
Francis R. Bach, Michael I. Jordan
Predictive low-rank decomposition for kernel methods.
Proceedings of the Twenty-second International Conference on Machine Learning (ICML) 2005
doi:10.1145/1102351.1102356.
Francis R. Bach, Michael I. Jordan
Kernel independent component analysis
Journal of Machine Learning Research 2002
doi:10.1162/153244303768966085
# approximation of a Gauss kernel matrix x <- rnorm(500) x_kernel_mat <- kernel_matrix(x, sigma = 1) x_chol <- incomplete_cholesky(x, sigma = 1) L_perm <- x_chol$L[x_chol$perm, ] x_kernel_approx <- L_perm %*% t(L_perm) ## largest differing value: max(abs(x_kernel_approx - x_kernel_mat)) # approximation of a Hermite kernel matrix x_kernel_mat <- kernel_matrix(x, kernel = "hermite", sigma = 0.5) x_chol <- incomplete_cholesky(x, kernel = "hermite", sigma = 0.5) L_perm <- x_chol$L[x_chol$perm, ] x_kernel_approx <- L_perm %*% t(L_perm) ## largest differing value: max(abs(x_kernel_approx - x_kernel_mat))# approximation of a Gauss kernel matrix x <- rnorm(500) x_kernel_mat <- kernel_matrix(x, sigma = 1) x_chol <- incomplete_cholesky(x, sigma = 1) L_perm <- x_chol$L[x_chol$perm, ] x_kernel_approx <- L_perm %*% t(L_perm) ## largest differing value: max(abs(x_kernel_approx - x_kernel_mat)) # approximation of a Hermite kernel matrix x_kernel_mat <- kernel_matrix(x, kernel = "hermite", sigma = 0.5) x_chol <- incomplete_cholesky(x, kernel = "hermite", sigma = 0.5) L_perm <- x_chol$L[x_chol$perm, ] x_kernel_approx <- L_perm %*% t(L_perm) ## largest differing value: max(abs(x_kernel_approx - x_kernel_mat))
The kernel ICA method by Bach and Jordan (see references). The contrast function was written in C++ under use of the Eigen3 library for computational speed. The package ManifoldOptim is utilized for minimization of the contrast function on the Stiefel manifold.
kernel_ica( x, variant = c("kgv", "kcca"), kernel = c("gauss", "hermite"), nstarts = 1, eps = 1e-04, sigma = ifelse(ncol(x) < 1000, 1, 0.5), kappa = ifelse(ncol(x) < 1000, 0.02, 0.002), hermite_rank = 3, init = MD_distant_matrices(p = ncol(x), n = nstarts), solver_params = ManifoldOptim::get.solver.params(), optim_method = "RSD" )kernel_ica( x, variant = c("kgv", "kcca"), kernel = c("gauss", "hermite"), nstarts = 1, eps = 1e-04, sigma = ifelse(ncol(x) < 1000, 1, 0.5), kappa = ifelse(ncol(x) < 1000, 0.02, 0.002), hermite_rank = 3, init = MD_distant_matrices(p = ncol(x), n = nstarts), solver_params = ManifoldOptim::get.solver.params(), optim_method = "RSD" )
x |
A numeric matrix, where each column contains the measurements of a mixed data source. |
variant |
Either |
kernel |
Either |
nstarts |
The number of restarts of the kernel ICA method with a default value of one. Ignored, if the starting values
in parameter |
eps |
Numeric precision parameter for the approximation of the kernel matrices. |
sigma |
Numeric value of the kernel variance. Default value is 1 for a given x with less than 1000 rows, otherwise 0.5. |
kappa |
Numeric dimming parameter. Default value is |
hermite_rank |
Integer. Rank of the hermite polynomial with a default value of 3. Ignored, when |
init |
A list of |
solver_params |
An object returned from the method |
optim_method |
The optimization method used in the Stiefel manifold. Default value is |
Several points need to be considered when using kernel_ica:
To comply with the notions of the JADE package, model
with a source matrix and a mixing matrix is assumed.
The returned unmixing matrix is found such that
results in the desired independent data.
It is not possible to reconstruct the original order of the sources nor their sign.
The contrast function which is to be minimized can have several local optimal.
Therefore setting the nstart parameter to a larger value than one or
instead providing more matrices in init for several starts should be considered.
Kernel ICA is started for each element given in the list init separately
and returns the best result by the lowest resulting value of the contrast function.
A class of type bss containing the following values:
the restored mean values
The unmixed data
The unmixing matrix
The smallest resulting contrast function value of all kernel ICA runs
Kernel ICA implementation in Matlab and C by F. Bach:
https://www.di.ens.fr/~fbach/kernel-ica/index.htm
Francis R. Bach, Michael I. Jordan
Kernel independent component analysis
Journal of Machine Learning Research 2002
doi:10.1162/153244303768966085
Sean Martin, Andrew M. Raim, Wen Huang, Kofi P. Adragni
ManifoldOptim: An R Interface to the ROPTLIB Library for Riemannian Manifold Optimization
Journal of Statistical Software 2020
doi:10.18637/jss.v093.i01
ManifoldOptim::manifold.optimManifoldOptim::get.solver.params
require(JADE) require(ICtest) n <- 2000 p <- 3 S <- matrix(0, n, p) # the three data sources used in this example S[, 1] <- rexp(n, rate = 0.4) S[, 2] <- runif(n, 2, 4) S[, 3] <- rt(n, 5) W <- ICtest::rorth(p) # creates an orthogonal matrix y <- S %*% t(W) # mixes the data # applying kernel ICA method res <- KernelICA::kernel_ica(y, variant = "kgv", kernel = "hermite") res$W # unmixing matrix apply(S, 2, mean) # original means res$Xmu # restored means (unordered and possibly with different sign each) # restored data z <- scale(res$S, center = -res$Xmu, scale = FALSE) # MD distance of the returned matrix to the original mixing matrix. JADE::MD(res$W, W) ## Not run: # Runs kernel ICA with the slower Gauss kernel method and # a the starting matrix returned from the first method call. # The maximal iteration number in the optimization is reduced to a tenth. res2 <- KernelICA::kernel_ica( y, variant = "kgv", kernel = "gauss", init = list(res$W), solver_params = ManifoldOptim::get.solver.params(Max_Iteration = 100) ) JADE::MD(res2$W, W) ## End(**Not run**)require(JADE) require(ICtest) n <- 2000 p <- 3 S <- matrix(0, n, p) # the three data sources used in this example S[, 1] <- rexp(n, rate = 0.4) S[, 2] <- runif(n, 2, 4) S[, 3] <- rt(n, 5) W <- ICtest::rorth(p) # creates an orthogonal matrix y <- S %*% t(W) # mixes the data # applying kernel ICA method res <- KernelICA::kernel_ica(y, variant = "kgv", kernel = "hermite") res$W # unmixing matrix apply(S, 2, mean) # original means res$Xmu # restored means (unordered and possibly with different sign each) # restored data z <- scale(res$S, center = -res$Xmu, scale = FALSE) # MD distance of the returned matrix to the original mixing matrix. JADE::MD(res$W, W) ## Not run: # Runs kernel ICA with the slower Gauss kernel method and # a the starting matrix returned from the first method call. # The maximal iteration number in the optimization is reduced to a tenth. res2 <- KernelICA::kernel_ica( y, variant = "kgv", kernel = "gauss", init = list(res$W), solver_params = ManifoldOptim::get.solver.params(Max_Iteration = 100) ) JADE::MD(res2$W, W) ## End(**Not run**)
Computes kernel matrices for Gaussian and Hermitian kernels.
kernel_matrix( x, y = x, kernel = c("gauss", "hermite"), sigma = 1, hermite_rank = 3 )kernel_matrix( x, y = x, kernel = c("gauss", "hermite"), sigma = 1, hermite_rank = 3 )
x |
Numeric vector. |
y |
Numeric vector, default is |
kernel |
Either |
sigma |
Numeric value of the kernel variance. Default is 1. |
hermite_rank |
Rank of the Hermite kernel. Default is 3. Ignored, when the Gaussian kernel is chosen. |
The function computes a matrix in the form of or
for a kernel function depending if a second vector was given. The following two kernels are offered:
Gauss Kernel:
Hermite Kernel:
where is the Hermite polynomial of grade
A numeric kernel matrix.
x <- rnorm(10) kernel_matrix(x, kernel = "gauss", sigma = 4) kernel_matrix(x, kernel = "hermite", sigma = 4, hermite_rank = 3)x <- rnorm(10) kernel_matrix(x, kernel = "gauss", sigma = 4) kernel_matrix(x, kernel = "hermite", sigma = 4, hermite_rank = 3)
Creates orthogonal matrices in the Stiefel manifold, which are distant to each other by the MD index and optionally also distant to a given set of matrices.
MD_distant_matrices(p, n = 1, mat_list = list(), bestof = 10)MD_distant_matrices(p, n = 1, mat_list = list(), bestof = 10)
p |
The dimension of the orthogonal matrices. |
n |
The length of the returned matrix list. |
mat_list |
A list of already existing orthogonal matrices. |
bestof |
The number of candidates evaluated for each new matrix. |
If a matrix list should be created from scratch, i.e. the parameter
mat_list was not provided, then the first orthogonal matrix
of the returned list is randomly generated by ICtest::rorth.
If n is larger than one or if a matrix list was provided,
then for each additional matrix we consider the distance
to all previous list entries. This distance is evaluated for bestof
randomly generated orthogonal candidate matrices from which the
furthest is selected.
A list which contains the already given and the additionally created matrices.
ICtest::rorth
# creates one orthogonal 3x3 matrix (result of ICtest::rorth(3)), wrapped in a list MD_distant_matrices(3, 1) # creates a 4x4 matrix, distant to the unit matrix and returns both MD_distant_matrices(4, 2, mat_list = list(diag(4))) # creates two orthogonal 3x3 matrices with more candidates to get better distances. m <- MD_distant_matrices(3, 2, bestof = 20) JADE::MD(m[[1]], m[[2]])# creates one orthogonal 3x3 matrix (result of ICtest::rorth(3)), wrapped in a list MD_distant_matrices(3, 1) # creates a 4x4 matrix, distant to the unit matrix and returns both MD_distant_matrices(4, 2, mat_list = list(diag(4))) # creates two orthogonal 3x3 matrices with more candidates to get better distances. m <- MD_distant_matrices(3, 2, bestof = 20) JADE::MD(m[[1]], m[[2]])