MLPACK  1.0.11
pca.hpp
Go to the documentation of this file.
1 
23 #ifndef __MLPACK_METHODS_PCA_PCA_HPP
24 #define __MLPACK_METHODS_PCA_PCA_HPP
25 
26 #include <mlpack/core.hpp>
27 
28 namespace mlpack {
29 namespace pca {
30 
38 class PCA
39 {
40  public:
47  PCA(const bool scaleData = false);
48 
58  void Apply(const arma::mat& data,
59  arma::mat& transformedData,
60  arma::vec& eigval,
61  arma::mat& eigvec) const;
62 
71  void Apply(const arma::mat& data,
72  arma::mat& transformedData,
73  arma::vec& eigVal) const;
74 
86  double Apply(arma::mat& data, const size_t newDimension) const;
87 
89  inline double Apply(arma::mat& data, const int newDimension) const
90  {
91  return Apply(data, size_t(newDimension));
92  }
93 
109  double Apply(arma::mat& data, const double varRetained) const;
110 
113  bool ScaleData() const { return scaleData; }
116  bool& ScaleData() { return scaleData; }
117 
118  // Returns a string representation of this object.
119  std::string ToString() const;
120 
121  private:
124  bool scaleData;
125 
126 }; // class PCA
127 
128 }; // namespace pca
129 }; // namespace mlpack
130 
131 #endif
std::string ToString() const
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.
This class implements principal components analysis (PCA).
Definition: pca.hpp:38
bool & ScaleData()
Modify whether or not this PCA object will scale (by standard deviation) the data when PCA is perform...
Definition: pca.hpp:116
bool scaleData
Whether or not the data will be scaled by standard deviation when PCA is performed.
Definition: pca.hpp:124
bool ScaleData() const
Get whether or not this PCA object will scale (by standard deviation) the data when PCA is performed...
Definition: pca.hpp:113
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:89
PCA(const bool scaleData=false)
Create the PCA object, specifying if the data should be scaled in each dimension by standard deviatio...