MLPACK  1.0.8
Public Member Functions | Private Member Functions | Private Attributes | List of all members
mlpack::kpca::KernelPCA< KernelType > Class Template Reference

This class performs kernel principal components analysis (Kernel PCA), for a given kernel. More...

Public Member Functions

 KernelPCA (const KernelType kernel=KernelType(), const bool centerTransformedData=false)
 Construct the KernelPCA object, optionally passing a kernel. More...
 
void Apply (const arma::mat &data, arma::mat &transformedData, arma::vec &eigval, arma::mat &eigvec)
 Apply Kernel Principal Components Analysis to the provided data set. More...
 
void Apply (const arma::mat &data, arma::mat &transformedData, arma::vec &eigval)
 Apply Kernel Principal Component Analysis to the provided data set. More...
 
void Apply (arma::mat &data, const size_t newDimension)
 Apply dimensionality reduction using Kernel Principal Component Analysis to the provided data set. More...
 
bool CenterTransformedData () const
 Return whether or not the transformed data is centered. More...
 
bool & CenterTransformedData ()
 Return whether or not the transformed data is centered. More...
 
const KernelType & Kernel () const
 Get the kernel. More...
 
KernelType & Kernel ()
 Modify the kernel. More...
 

Private Member Functions

void GetKernelMatrix (const arma::mat &data, arma::mat &kernelMatrix)
 Construct the kernel matrix. More...
 

Private Attributes

bool centerTransformedData
 If true, the data will be scaled (by standard deviation) when Apply() is run. More...
 
KernelType kernel
 The instantiated kernel. More...
 

Detailed Description

template<typename KernelType>
class mlpack::kpca::KernelPCA< KernelType >

This class performs kernel principal components analysis (Kernel PCA), for a given kernel.

This is a standard machine learning technique and is well-documented on the Internet and in standard texts. It is often used as a dimensionality reduction technique, and can also be useful in mapping linearly inseparable classes of points to different spaces where they are linearly separable.

The performance of the method is highly dependent on the kernel choice. There are numerous available kernels in the mlpack::kernel namespace (see files in mlpack/core/kernels/) and it is easy to write your own; see other implementations for examples.

Definition at line 46 of file kernel_pca.hpp.

Constructor & Destructor Documentation

template<typename KernelType >
mlpack::kpca::KernelPCA< KernelType >::KernelPCA ( const KernelType  kernel = KernelType(),
const bool  centerTransformedData = false 
)

Construct the KernelPCA object, optionally passing a kernel.

Optionally, the transformed data can be centered about the origin; to do this, pass 'true' for centerTransformedData. This will take slightly longer (but not much).

Parameters
kernelKernel to be used for computation.

Member Function Documentation

template<typename KernelType >
void mlpack::kpca::KernelPCA< KernelType >::Apply ( const arma::mat &  data,
arma::mat &  transformedData,
arma::vec &  eigval,
arma::mat &  eigvec 
)

Apply Kernel Principal Components Analysis to the provided data set.

Parameters
dataData matrix.
transformedDataMatrix to output results into.
eigvalKPCA eigenvalues will be written to this vector.
eigvecKPCA eigenvectors will be written to this matrix.
template<typename KernelType >
void mlpack::kpca::KernelPCA< KernelType >::Apply ( const arma::mat &  data,
arma::mat &  transformedData,
arma::vec &  eigval 
)

Apply Kernel Principal Component Analysis to the provided data set.

Parameters
dataData matrix.
transformedDataMatrix to output results into.
eigvalKPCA eigenvalues will be written to this vector.
template<typename KernelType >
void mlpack::kpca::KernelPCA< KernelType >::Apply ( arma::mat &  data,
const size_t  newDimension 
)

Apply dimensionality reduction using Kernel Principal Component Analysis to the provided data set.

The data matrix will be modified in-place. Note that the dimension can be larger than the existing dimension because KPCA works on the kernel matrix, not the covariance matrix. This means the new dimension can be as large as the number of points (columns) in the dataset. Note that if you specify newDimension to be larger than the current dimension of the data (the number of rows), then it's not really "dimensionality reduction"...

Parameters
dataData matrix.
newDimensionNew dimension for the dataset.
template<typename KernelType >
bool mlpack::kpca::KernelPCA< KernelType >::CenterTransformedData ( ) const
inline

Return whether or not the transformed data is centered.

Definition at line 105 of file kernel_pca.hpp.

References mlpack::kpca::KernelPCA< KernelType >::centerTransformedData.

template<typename KernelType >
bool& mlpack::kpca::KernelPCA< KernelType >::CenterTransformedData ( )
inline

Return whether or not the transformed data is centered.

Definition at line 107 of file kernel_pca.hpp.

References mlpack::kpca::KernelPCA< KernelType >::centerTransformedData.

template<typename KernelType >
void mlpack::kpca::KernelPCA< KernelType >::GetKernelMatrix ( const arma::mat &  data,
arma::mat &  kernelMatrix 
)
private

Construct the kernel matrix.

Parameters
dataInput data points.
kernelMatrixMatrix to store the constructed kernel matrix in.
template<typename KernelType >
const KernelType& mlpack::kpca::KernelPCA< KernelType >::Kernel ( ) const
inline

Get the kernel.

Definition at line 100 of file kernel_pca.hpp.

References mlpack::kpca::KernelPCA< KernelType >::kernel.

template<typename KernelType >
KernelType& mlpack::kpca::KernelPCA< KernelType >::Kernel ( )
inline

Modify the kernel.

Definition at line 102 of file kernel_pca.hpp.

References mlpack::kpca::KernelPCA< KernelType >::kernel.

Member Data Documentation

template<typename KernelType >
bool mlpack::kpca::KernelPCA< KernelType >::centerTransformedData
private

If true, the data will be scaled (by standard deviation) when Apply() is run.

Definition at line 114 of file kernel_pca.hpp.

Referenced by mlpack::kpca::KernelPCA< KernelType >::CenterTransformedData().

template<typename KernelType >
KernelType mlpack::kpca::KernelPCA< KernelType >::kernel
private

The instantiated kernel.

Definition at line 111 of file kernel_pca.hpp.

Referenced by mlpack::kpca::KernelPCA< KernelType >::Kernel().


The documentation for this class was generated from the following file: