mlpack  3.4.2
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 
115  bool CenterTransformedData() const { return centerTransformedData; }
117  bool& CenterTransformedData() { return centerTransformedData; }
118 
119  private:
121  KernelType kernel;
124  bool centerTransformedData;
125 }; // class KernelPCA
126 
127 } // namespace kpca
128 } // namespace mlpack
129 
130 // Include implementation.
131 #include "kernel_pca_impl.hpp"
132 
133 #endif // MLPACK_METHODS_KERNEL_PCA_KERNEL_PCA_HPP
This class performs kernel principal components analysis (Kernel PCA), for a given kernel.
Definition: kernel_pca.hpp:41
bool & CenterTransformedData()
Return whether or not the transformed data is centered.
Definition: kernel_pca.hpp:117
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.
const KernelType & Kernel() const
Get the kernel.
Definition: kernel_pca.hpp:110
bool CenterTransformedData() const
Return whether or not the transformed data is centered.
Definition: kernel_pca.hpp:115
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.
KernelType & Kernel()
Modify the kernel.
Definition: kernel_pca.hpp:112
KernelPCA(const KernelType kernel=KernelType(), const bool centerTransformedData=false)
Construct the KernelPCA object, optionally passing a kernel.
void Apply(const arma::mat &data, arma::mat &transformedData, arma::vec &eigval)
Apply Kernel Principal Component Analysis to the provided data set.
void Apply(arma::mat &data, const size_t newDimension)
Apply dimensionality reduction using Kernel Principal Component Analysis to the provided data set.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.