public class KPCA<T> extends java.lang.Object implements Projection<T>, java.io.Serializable
In practice, a large data set leads to a large Kernel/Gram matrix K, and storing K may become a problem. One way to deal with this is to perform clustering on your large dataset, and populate the kernel with the means of those clusters. Since even this method may yield a relatively large K, it is common to compute only the top P eigenvalues and eigenvectors of K.
Kernel PCA with an isotropic kernel function is closely related to metric MDS. Carrying out metric MDS on the kernel matrix K produces an equivalent configuration of points as the distance (2(1 - K(xi, xj)))1/2 computed in feature space.
Kernel PCA also has close connections with Isomap, LLE, and Laplacian eigenmaps.
MercerKernel,
PCA,
IsoMap,
LLE,
LaplacianEigenmap,
SammonMapping,
Serialized Form| Constructor and Description |
|---|
KPCA(T[] data,
smile.math.kernel.MercerKernel<T> kernel,
double[] mean,
double mu,
double[][] coordinates,
double[] latent,
smile.math.matrix.Matrix projection)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static <T> KPCA<T> |
fit(T[] data,
smile.math.kernel.MercerKernel<T> kernel,
int k)
Fits kernel principal component analysis.
|
static <T> KPCA<T> |
fit(T[] data,
smile.math.kernel.MercerKernel<T> kernel,
int k,
double threshold)
Fits kernel principal component analysis.
|
double[][] |
getCoordinates()
Returns the nonlinear principal component scores, i.e., the representation
of learning data in the nonlinear principal component space.
|
smile.math.matrix.Matrix |
getProjection()
Returns the projection matrix.
|
double[] |
getVariances()
Returns the eigenvalues of kernel principal components, ordered from largest to smallest.
|
double[] |
project(T x)
Project a data point to the feature space.
|
double[][] |
project(T[] x)
Project a set of data to the feature space.
|
public KPCA(T[] data, smile.math.kernel.MercerKernel<T> kernel, double[] mean, double mu, double[][] coordinates, double[] latent, smile.math.matrix.Matrix projection)
data - training data.kernel - Mercer kernel.mean - the row/column average of kernel matrix.mu - the average of kernel matrix.coordinates - the coordinates of projected training data.latent - the projection matrix.projection - the projection matrix.public static <T> KPCA<T> fit(T[] data, smile.math.kernel.MercerKernel<T> kernel, int k)
data - training data.kernel - Mercer kernel.k - choose up to k principal components (larger than 0.0001) used for projection.public static <T> KPCA<T> fit(T[] data, smile.math.kernel.MercerKernel<T> kernel, int k, double threshold)
data - training data.kernel - Mercer kernel.k - choose top k principal components used for projection.threshold - only principal components with eigenvalues
larger than the given threshold will be kept.public double[] getVariances()
public smile.math.matrix.Matrix getProjection()
public double[][] getCoordinates()
public double[] project(T x)
Projectionproject in interface Projection<T>public double[][] project(T[] x)
Projectionproject in interface Projection<T>