mlpack  2.0.1
pca.hpp
Go to the documentation of this file.
1 
15 #ifndef __MLPACK_METHODS_PCA_PCA_HPP
16 #define __MLPACK_METHODS_PCA_PCA_HPP
17 
18 #include <mlpack/core.hpp>
19 
20 namespace mlpack {
21 namespace pca {
22 
30 class PCA
31 {
32  public:
39  PCA(const bool scaleData = false);
40 
50  void Apply(const arma::mat& data,
51  arma::mat& transformedData,
52  arma::vec& eigval,
53  arma::mat& eigvec) const;
54 
63  void Apply(const arma::mat& data,
64  arma::mat& transformedData,
65  arma::vec& eigVal) const;
66 
78  double Apply(arma::mat& data, const size_t newDimension) const;
79 
81  inline double Apply(arma::mat& data, const int newDimension) const
82  {
83  return Apply(data, size_t(newDimension));
84  }
85 
101  double Apply(arma::mat& data, const double varRetained) const;
102 
105  bool ScaleData() const { return scaleData; }
108  bool& ScaleData() { return scaleData; }
109 
110  private:
113  bool scaleData;
114 
115 }; // class PCA
116 
117 } // namespace pca
118 } // namespace mlpack
119 
120 #endif
double Apply(arma::mat &data, const int newDimension) const
This overload is here to make sure int gets casted right to size_t.
Definition: pca.hpp:81
Linear algebra utility functions, generally performed on matrices or vectors.
This class implements principal components analysis (PCA).
Definition: pca.hpp:30
bool & ScaleData()
Modify whether or not this PCA object will scale (by standard deviation) the data when PCA is perform...
Definition: pca.hpp:108
bool scaleData
Whether or not the data will be scaled by standard deviation when PCA is performed.
Definition: pca.hpp:113
void Apply(const arma::mat &data, arma::mat &transformedData, arma::vec &eigval, arma::mat &eigvec) const
Apply Principal Component Analysis to the provided data set.
PCA(const bool scaleData=false)
Create the PCA object, specifying if the data should be scaled in each dimension by standard deviatio...
Include all of the base components required to write MLPACK methods, and the main MLPACK Doxygen docu...
bool ScaleData() const
Get whether or not this PCA object will scale (by standard deviation) the data when PCA is performed...
Definition: pca.hpp:105