16 #ifndef MLPACK_METHODS_PCA_PCA_HPP 17 #define MLPACK_METHODS_PCA_PCA_HPP 32 template<
typename DecompositionPolicy = ExactSVDPolicy>
43 PCA(
const bool scaleData =
false,
44 const DecompositionPolicy& decomposition = DecompositionPolicy());
55 void Apply(
const arma::mat& data,
56 arma::mat& transformedData,
68 void Apply(
const arma::mat& data,
69 arma::mat& transformedData,
77 void Apply(
const arma::mat& data,
78 arma::mat& transformedData);
91 double Apply(arma::mat& data,
const size_t newDimension);
94 inline double Apply(arma::mat& data,
const int newDimension)
96 return Apply(data,
size_t(newDimension));
114 double Apply(arma::mat& data,
const double varRetained);
132 arma::vec stdDev = arma::stddev(
133 centeredData, 0, 1 );
136 for (
size_t i = 0; i < stdDev.n_elem; ++i)
140 centeredData /= arma::repmat(stdDev, 1, centeredData.n_cols);
149 DecompositionPolicy decomposition;
156 #include "pca_impl.hpp" void Apply(const arma::mat &data, arma::mat &transformedData, arma::vec &eigVal, arma::mat &eigvec)
Apply Principal Component Analysis to the provided data set.
Linear algebra utility functions, generally performed on matrices or vectors.
bool & ScaleData()
Modify whether or not this PCA object will scale (by standard deviation) the data when PCA is perform...
The core includes that mlpack expects; standard C++ includes and Armadillo.
This class implements principal components analysis (PCA).
PCA(const bool scaleData=false, const DecompositionPolicy &decomposition=DecompositionPolicy())
Create the PCA object, specifying if the data should be scaled in each dimension by standard deviatio...
bool ScaleData() const
Get whether or not this PCA object will scale (by standard deviation) the data when PCA is performed...
double Apply(arma::mat &data, const int newDimension)
This overload is here to make sure int gets casted right to size_t.