mlpack  1.0.12
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  // Returns a string representation of this object.
111  std::string ToString() const;
112 
113  private:
116  bool scaleData;
117 
118 }; // class PCA
119 
120 }; // namespace pca
121 }; // namespace mlpack
122 
123 #endif
std::string ToString() const
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: load.hpp:23
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: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:116
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
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
PCA(const bool scaleData=false)
Create the PCA object, specifying if the data should be scaled in each dimension by standard deviatio...