Online Kernel PCA
Abstract
Describe a new method for performing kernel principal component analysis which is online and also has a fast convergence rate. The method follows the Rayleigh quotient to obtain a fixed point update rule to extract the leading eigenvalue and eigenvector. Online deflation is used to estimate the remaining components. These operations are performed in reproducing kernel Hilbert space (RKHS) with linear order memory and computation complexity.
Background
Principal component analysis
Given a set of centered observations such that the covariance matrix is and its estimate is . PCA orthogonalizes the covariance matrix by solving , for eigenvalues and their corresponding eigenvectors .
Rayleigh quotient algorithm (RQA)
An important result from the Rayleigh-Ritz theorem is that to compute the largest eigenvalue and its corresponding eigenvector, one only needs to maximize the Rayleigh quotient with respect to . The resulting quotient, , is the largest eigenvalue. Taking the derivative of the quotient with respect to and considering that , which is valid for eigenvectors, results in . To solve the PCA problem online, need to estimate the eigenvector at sample [1] as: , where is the estimate of the covariance matrix after the observation and is the estimate of the eigenvector at observation . Replacing the estimate of the covariance matrix results in . The online version simplifies to
where providing a simple rule to update the eigenvector as more samples are introduced.
Kernel principal component analysis
Since PCA fails to capture the structure of highly nonlinear datasets, KPCA was introduced as a nonlinear extension to PCA. KPCA first transforms the data into a feature space F of much higher dimension and then computes the PCA of the data in that space. The inner product between the transformed data in the feature space is evaluated using the kernel function , where is the nonlinear mapping from the input space into the feature Hilbert space , . The kernel function allows us to compute the inner product between two points in feature space without having to know the mapping explicitly.
Since PCA can be written in terms of inner products, it can be implicitly computed in feature space. Assuming that the transformed data in feature space are also centered, the covariance matrix is then estimated as . To perform PCA, since the eigenvectors lie within the span of , the following equivalent problem is considered: , where and , and could be represented in terms of a -dimensional vector as . Defining the Gram matrix and combining with the two equations above we get $latex \mathbf{K}\mathbf{q} = N\lambda\mathbf{q}$, which provides the eigenvalues and eigenvectors of the data in feature space. The main problem with KPCA is that the Gram matrix size increases with the number of observations, thus becoming computationally infeasible to solve directly and in particular online.
Kernel Rayleigh quotient algorithm (KRQA)
If we consider the observations transformed in the feature space, the leading eigenvector is computed as:
where , since all nonzero solutions lie within the span of . Using the reproducing kernel property, we have
.
Expanding further, we have a similar update rule as in the input space
,
where . The only difference is that since an actual eigenvector in the feature space does not exist, but it is rather a representation in terms of the previous observations, inner products are required to compute the coefficient of the new observation.
Insuring the observations are centered
The derivations above assume that the data are centered in which is not generally true. Therefore, the mean needs to be subtracted from each sample. The observation is then replaced with . The update rule above is extended to include subtraction of mean from each pair of samples. Thus replacing with , where and .
Rule for minor components
The minor eigencomponents can be estimated using the deflation technique. The largest eigencomponent is calculated over the whole space as described above. The next largest eigencomponent is calculated by restricting attention to the subspace which is orthogonal complement of the first eigenvector. The covariance matrix becomes . The observations are also restricted to this subspace . The update equations remain the same except that the observations are replaced with new observations where the projection onto the first eigenvector is first removed. This process is then followed for the rest of the eigencomponents where projections onto the second eigenvector are then removed. Need to keep in mind that while updates in input space are very simple and previous values can be used to estimate future ones, this is not that simple in feature space, where, as mentioned above, the exact transformation is not known and thus the actual values cannot be stored. While in the input space the computation complexity always remains in the feature space the complexity increases linearly, , in contrast to the direct solution, .
Experiments and Results
Toy Example
To demonstrate the capability of kernel RQA (KRQA) we compare it against KPCA and kernel General Hebbian algorithm (KGHA) in a toy example. The data is generated in the following way: x-values have uniform distribution in [-1,1], y-values are generated from , where $\xi$ is normal noise with standard deviation 0.2. Two hundred samples were used in the iterative method (KGHA) until convergence was reached. The same 200 samples were used in our online update algorithm but they were repeated 300 times (since 200 is not enough for only one pass). In both cases, the kernel used was a second order polynomial. The figure below shows an example of part of the dataset and the three eigenvectors representing the data.
The Monte Carlo simulation results for 100 times are shown in the table below, where we compare the accuracy of our method, KRQA, against the iterative method KGHA and the actual eigenvalues obtained from KPCA. The table shows that KRQA is far more accurate than KGHA. In addition, KRQA has a much faster convergence rate only 300 iterations needed compared to 7752 required for KGHA. Recall that in both KGHA and KRQA, the time and memory complexity for each iteration are and , where is the number of principal components, is the current number of samples, and is the input space dimensionality.
KPCA | KGHA | KRQA | |
Iterations | - | 7752 | 300 |
λ_{1} | 0.32198 | ±2.5×10^{-3} | ±1.0×10^{-5} |
λ_{2} | 0.16891 | ±1.9×10^{-2} | ±3.0×10^{-5} |
λ_{3} | 0.02044 | ±3.9×10^{-4} | ±1.0×10^{-4} |
Noise Reduction
Test KRQA on noise reduction in data collected incrementally. The data is sampled from a modulated sine wave with Gaussian noise of standard deviation 0.1. The system was trained on 5000 samples presented only once online, and then tested on the set shown in the figure below. A Gaussian kernel with kernel size 0.2 was used to train the system. Three principal components were extracted and used to reconstruct the data samples. Since the manipulations occur in feature space, a preimaging method, , was used to retrieve the data from the feature space to the input space. The figure below shows the training results where the data samples are in blue, the data transferred to feature space and retrieved, , are in green, and the reconstructed samples are in red. The figure shows that the reconstruction is capable of removing most of the noise in the signal with minor mistakes.
Data Reconstruction
Test the method on reconstruction of data using only a small number of principal components. The system was trained with a Gaussian kernel and kernel size 7.5. Handwritten digits were introduced sequentially and the first ten principal components were updated online. The figure below shows the original testing digits and the reconstruction results after 250, 500, 750, and 1000 images per digit were introduced to the system. It is important to emphasize that the system was trained online and the training images were presented only once. The MSE results show how the system continues to improve as more samples are introduced.
The table shows the classification error rates of KRQA and KPCA using least squares regression and one versus all configuration. As expected, the performance improves with the number of PCs extracted. In addition, the KRQA performs fairly close to KPCA.
16 | 32 | 64 | |
KPCA | 0.251 | 0.172 | 0.124 |
KRQA | 0.261 | 0.197 | 0.147 |