MLPACK  1.0.11
kernel_pca.hpp
Go to the documentation of this file.
1 
24 #ifndef __MLPACK_METHODS_KERNEL_PCA_KERNEL_PCA_HPP
25 #define __MLPACK_METHODS_KERNEL_PCA_KERNEL_PCA_HPP
26 
27 #include <mlpack/core.hpp>
29 
30 namespace mlpack {
31 namespace kpca {
32 
46 template <
47  typename KernelType,
48  typename KernelRule = NaiveKernelRule<KernelType>
49 >
50 class KernelPCA
51 {
52  public:
62  KernelPCA(const KernelType kernel = KernelType(),
63  const bool centerTransformedData = false);
64 
74  void Apply(const arma::mat& data,
75  arma::mat& transformedData,
76  arma::vec& eigval,
77  arma::mat& eigvec,
78  const size_t newDimension);
79 
88  void Apply(const arma::mat& data,
89  arma::mat& transformedData,
90  arma::vec& eigval,
91  arma::mat& eigvec);
92 
100  void Apply(const arma::mat& data,
101  arma::mat& transformedData,
102  arma::vec& eigval);
103 
117  void Apply(arma::mat& data, const size_t newDimension);
118 
120  const KernelType& Kernel() const { return kernel; }
122  KernelType& Kernel() { return kernel; }
123 
128 
129  // Returns a string representation of this object.
130  std::string ToString() const;
131 
132  private:
134  KernelType kernel;
138 
139 }; // class KernelPCA
140 
141 }; // namespace kpca
142 }; // namespace mlpack
143 
144 // Include implementation.
145 #include "kernel_pca_impl.hpp"
146 
147 #endif // __MLPACK_METHODS_KERNEL_PCA_KERNEL_PCA_HPP
KernelType kernel
The instantiated kernel.
Definition: kernel_pca.hpp:134
KernelPCA(const KernelType kernel=KernelType(), const bool centerTransformedData=false)
Construct the KernelPCA object, optionally passing a kernel.
std::string ToString() const
bool & CenterTransformedData()
Return whether or not the transformed data is centered.
Definition: kernel_pca.hpp:127
void Apply(const arma::mat &data, arma::mat &transformedData, arma::vec &eigval, arma::mat &eigvec, const size_t newDimension)
Apply Kernel Principal Components Analysis to the provided data set.
bool centerTransformedData
If true, the data will be scaled (by standard deviation) when Apply() is run.
Definition: kernel_pca.hpp:137
KernelType & Kernel()
Modify the kernel.
Definition: kernel_pca.hpp:122
const KernelType & Kernel() const
Get the kernel.
Definition: kernel_pca.hpp:120
This class performs kernel principal components analysis (Kernel PCA), for a given kernel...
Definition: kernel_pca.hpp:50
bool CenterTransformedData() const
Return whether or not the transformed data is centered.
Definition: kernel_pca.hpp:125