mlpack  master
kernel_pca.hpp
Go to the documentation of this file.
1 
14 #ifndef MLPACK_METHODS_KERNEL_PCA_KERNEL_PCA_HPP
15 #define MLPACK_METHODS_KERNEL_PCA_KERNEL_PCA_HPP
16 
17 #include <mlpack/prereqs.hpp>
19 
20 namespace mlpack {
21 namespace kpca {
22 
36 template <
37  typename KernelType,
38  typename KernelRule = NaiveKernelRule<KernelType>
39 >
40 class KernelPCA
41 {
42  public:
52  KernelPCA(const KernelType kernel = KernelType(),
53  const bool centerTransformedData = false);
54 
64  void Apply(const arma::mat& data,
65  arma::mat& transformedData,
66  arma::vec& eigval,
67  arma::mat& eigvec,
68  const size_t newDimension);
69 
78  void Apply(const arma::mat& data,
79  arma::mat& transformedData,
80  arma::vec& eigval,
81  arma::mat& eigvec);
82 
90  void Apply(const arma::mat& data,
91  arma::mat& transformedData,
92  arma::vec& eigval);
93 
107  void Apply(arma::mat& data, const size_t newDimension);
108 
110  const KernelType& Kernel() const { return kernel; }
112  KernelType& Kernel() { return kernel; }
113 
118 
119  private:
121  KernelType kernel;
125 
126 }; // class KernelPCA
127 
128 } // namespace kpca
129 } // namespace mlpack
130 
131 // Include implementation.
132 #include "kernel_pca_impl.hpp"
133 
134 #endif // MLPACK_METHODS_KERNEL_PCA_KERNEL_PCA_HPP
KernelType kernel
The instantiated kernel.
Definition: kernel_pca.hpp:121
KernelPCA(const KernelType kernel=KernelType(), const bool centerTransformedData=false)
Construct the KernelPCA object, optionally passing a kernel.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: binarize.hpp:18
bool & CenterTransformedData()
Return whether or not the transformed data is centered.
Definition: kernel_pca.hpp:117
The core includes that mlpack expects; standard C++ includes and Armadillo.
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:124
KernelType & Kernel()
Modify the kernel.
Definition: kernel_pca.hpp:112
const KernelType & Kernel() const
Get the kernel.
Definition: kernel_pca.hpp:110
This class performs kernel principal components analysis (Kernel PCA), for a given kernel...
Definition: kernel_pca.hpp:40
bool CenterTransformedData() const
Return whether or not the transformed data is centered.
Definition: kernel_pca.hpp:115