MLPACK  1.0.7
kernel_pca.hpp
Go to the documentation of this file.
1 
23 #ifndef __MLPACK_METHODS_KERNEL_PCA_KERNEL_PCA_HPP
24 #define __MLPACK_METHODS_KERNEL_PCA_KERNEL_PCA_HPP
25 
26 #include <mlpack/core.hpp>
28 
29 namespace mlpack {
30 namespace kpca {
31 
45 template <typename KernelType>
46 class KernelPCA
47 {
48  public:
57  KernelPCA(const KernelType kernel = KernelType(),
58  const bool centerTransformedData = false);
59 
68  void Apply(const arma::mat& data,
69  arma::mat& transformedData,
70  arma::vec& eigval,
71  arma::mat& eigvec);
72 
80  void Apply(const arma::mat& data,
81  arma::mat& transformedData,
82  arma::vec& eigval);
83 
97  void Apply(arma::mat& data, const size_t newDimension);
98 
100  const KernelType& Kernel() const { return kernel; }
102  KernelType& Kernel() { return kernel; }
103 
108 
109  private:
111  KernelType kernel;
115 
122  void GetKernelMatrix(const arma::mat& data, arma::mat& kernelMatrix);
123 
124 }; // class KernelPCA
125 
126 }; // namespace kpca
127 }; // namespace mlpack
128 
129 // Include implementation.
130 #include "kernel_pca_impl.hpp"
131 
132 #endif // __MLPACK_METHODS_KERNEL_PCA_KERNEL_PCA_HPP
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.
void GetKernelMatrix(const arma::mat &data, arma::mat &kernelMatrix)
Construct the kernel matrix.
const KernelType & Kernel() const
Get the kernel.
Definition: kernel_pca.hpp:100
KernelPCA(const KernelType kernel=KernelType(), const bool centerTransformedData=false)
Construct the KernelPCA object, optionally passing a kernel.
bool & CenterTransformedData()
Return whether or not the transformed data is centered.
Definition: kernel_pca.hpp:107
KernelType & Kernel()
Modify the kernel.
Definition: kernel_pca.hpp:102
bool centerTransformedData
If true, the data will be scaled (by standard deviation) when Apply() is run.
Definition: kernel_pca.hpp:114
KernelType kernel
The instantiated kernel.
Definition: kernel_pca.hpp:111
This class performs kernel principal components analysis (Kernel PCA), for a given kernel...
Definition: kernel_pca.hpp:46
bool CenterTransformedData() const
Return whether or not the transformed data is centered.
Definition: kernel_pca.hpp:105