latest version v1.9 - last update 10 Apr 2010 |
Functor for computing a kernel principal component analysis. More...
#include <ltiKPCA.h>
Classes | |
class | parameters |
the parameters for the class principalComponents More... | |
Public Member Functions | |
kernelPCA () | |
kernelPCA (const kernelPCA &other) | |
virtual | ~kernelPCA () |
virtual const char * | getTypeName () const |
virtual bool | apply (const dmatrix &data, dmatrix &result) |
virtual bool | apply (dmatrix &srcdest) |
bool | apply (const dvector &src, dvector &result) |
virtual bool | transform (const dvector &src, dvector &result) const |
virtual bool | transform (const dmatrix &src, dmatrix &result) const |
virtual bool | transform (dmatrix &srcdest) const |
virtual bool | computeTransformMatrix (const dmatrix &src) |
virtual bool | train (const dmatrix &src) |
virtual bool | getEigenValues (dvector &result) const |
virtual const dvector & | getEigenValues () const |
virtual bool | getEigenVectors (dmatrix &result) const |
virtual const dmatrix & | getEigenVectors () const |
virtual void | setDimension (int k) |
kernelPCA & | copy (const kernelPCA &other) |
virtual functor * | clone () const |
const parameters & | getParameters () const |
virtual bool | updateParameters () |
virtual bool | read (ioHandler &handler, const bool complete=true) |
virtual bool | write (ioHandler &handler, const bool complete=true) const |
int | getUsedDimension () const |
Protected Member Functions | |
int | checkDim () |
bool | computeKernelMatrix (const dmatrix &src, dmatrix &kmat) |
bool | computeTestKernelMatrix (const dmatrix &src, dmatrix &kmat) const |
bool | computeTestKernelVector (const dvector &src, dvector &kvct) const |
Functor for computing a kernel principal component analysis.
It receives a set of input vectors in form of a matrix (each row of the matrix corresponds to an input vector), which will be transformed with KPCA.
The first time you use the apply()-method, the transformation matrix will be computed. You can use this transformation matrix with other data sets using the transform() methods.
Please note that the eigenvector matrices will contain the eigenvector in the COLUMNS and not in the rows, as could be expected. This avoids the requirement of transposing matrices in the vector transformations (see also lti::eigenSystem<T>).
The Kernel PCA is described in Schoelkopf, B., Smola, A. and Mueller, K. "Nonlinear Component Analysis as a Kernel Eigenvalue Problem", Neural Computation, vol. 10, no. 5, pp. 1299-1319
lti::kernelPCA::kernelPCA | ( | ) |
default constructor
lti::kernelPCA::kernelPCA | ( | const kernelPCA & | other | ) |
copy constructor
other | the object to be copied |
virtual lti::kernelPCA::~kernelPCA | ( | ) | [virtual] |
destructor
Transforms a single vector according to a previously computed transformation matrix.
(this is an alias for the transform() method)
References transform().
virtual bool lti::kernelPCA::apply | ( | dmatrix & | srcdest | ) | [virtual] |
On-Place version of the transformation.
If you don't need to transform the input data, and just want to use the input matrix to compute the principal components you can use the method computeTransformMatrix(). If you just need to transform the data, without computing the transformation matrix, you can use the method transform().
srcdest | dmatrix with the source data, which will also contain the result. |
srcdest
. Computes the principal components of the data matrix and transforms it according to the new coordinate system.
The result is the transformed matrix. data and result must not be references to the same matrix. This method uses the eigenvector functor given in the parameters. By default, it uses ltilib's own jacobi functor. However, you can speed it up considerably by using the eigensystem functor in the lamath directory.
If you don't need to transform the input data, and just want to use the input matrix to compute the principal components you can use the method computeTransformMatrix(). If you just need to transform the data, without computing the transformation matrix, you can use the method transform().
data | dmatrix with the source data. | |
result | dmatrix with the result data. |
int lti::kernelPCA::checkDim | ( | ) | [protected] |
Determines the intrinsic dimensionality of the data set if the user specify autoDim, otherwise return parameters::resultDim.
The member usedDimensionality will be set with the returned value
virtual functor* lti::kernelPCA::clone | ( | ) | const [virtual] |
returns a pointer to a clone of this functor.
Implements lti::functor.
compute kernel matrix.
The data will be centered.
bool lti::kernelPCA::computeTestKernelMatrix | ( | const dmatrix & | src, | |
dmatrix & | kmat | |||
) | const [protected] |
compute test kernel matrix.
The data will be centered. It will be assumed that the source data (srcData) contains the right data
bool lti::kernelPCA::computeTestKernelVector | ( | const dvector & | src, | |
dvector & | kvct | |||
) | const [protected] |
compute test kernel vector.
The data will be centered. It will be assumed that the source data (srcData) contains the right data
virtual bool lti::kernelPCA::computeTransformMatrix | ( | const dmatrix & | src | ) | [virtual] |
copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::functor.
virtual const dvector& lti::kernelPCA::getEigenValues | ( | ) | const [virtual] |
Returns the previously computed eigenvalues of the covariance matrix.
virtual bool lti::kernelPCA::getEigenValues | ( | dvector & | result | ) | const [virtual] |
virtual const dmatrix& lti::kernelPCA::getEigenVectors | ( | ) | const [virtual] |
virtual bool lti::kernelPCA::getEigenVectors | ( | dmatrix & | result | ) | const [virtual] |
Returns the previously computed eigenvectors of the covariance matrix.
Each ROW (as opposite to PCA) will contain the eigenvectors.
result | the matrix which will receive the eigenvectors. Each row of the matrix contains one eigenvector. |
const parameters& lti::kernelPCA::getParameters | ( | ) | const |
returns used parameters
Reimplemented from lti::functor.
virtual const char* lti::kernelPCA::getTypeName | ( | ) | const [virtual] |
returns the name of this type ("kernelPCA")
Reimplemented from lti::linearAlgebraFunctor.
int lti::kernelPCA::getUsedDimension | ( | ) | const [inline] |
Number of dimensions considered in the transformation.
virtual bool lti::kernelPCA::read | ( | ioHandler & | handler, | |
const bool | complete = true | |||
) | [virtual] |
Reads this functor from the given handler.
Reimplemented from lti::functor.
virtual void lti::kernelPCA::setDimension | ( | int | k | ) | [virtual] |
Set the dimension to which the vectors should be reduced.
virtual bool lti::kernelPCA::train | ( | const dmatrix & | src | ) | [virtual] |
Alias for computeTransformMatrix().
virtual bool lti::kernelPCA::transform | ( | dmatrix & | srcdest | ) | const [virtual] |
virtual bool lti::kernelPCA::updateParameters | ( | ) | [virtual] |
set functor's parameters.
This member makes a copy of theParam: the functor will keep its own copy of the parameters!
Reimplemented from lti::functor.
virtual bool lti::kernelPCA::write | ( | ioHandler & | handler, | |
const bool | complete = true | |||
) | const [virtual] |
Writes this functor to the given handler.
Reimplemented from lti::functor.