16 #ifndef MLPACK_METHODS_PCA_PCA_HPP 17 #define MLPACK_METHODS_PCA_PCA_HPP 33 template<
typename DecompositionPolicy = ExactSVDPolicy>
43 PCAType(
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,
83 double Apply(arma::mat& data,
const size_t newDimension);
86 inline double Apply(arma::mat& data,
const int newDimension)
88 return Apply(data,
size_t(newDimension));
106 double Apply(arma::mat& data,
const double varRetained);
124 arma::vec stdDev = arma::stddev(
125 centeredData, 0, 1 );
128 for (
size_t i = 0; i < stdDev.n_elem; ++i)
132 centeredData /= arma::repmat(stdDev, 1, centeredData.n_cols);
141 DecompositionPolicy decomposition;
151 #include "pca_impl.hpp" double Apply(arma::mat &data, const int newDimension)
This overload is here to make sure int gets casted right to size_t.
Linear algebra utility functions, generally performed on matrices or vectors.
This class implements principal components analysis (PCA).
The core includes that mlpack expects; standard C++ includes and Armadillo.
PCAType< ExactSVDPolicy > PCA
3.0.0 TODO: break reverse-compatibility by changing PCAType to PCA.
PCAType(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...
void Apply(const arma::mat &data, arma::mat &transformedData, arma::vec &eigVal, arma::mat &eigvec)
Apply Principal Component Analysis to the provided data set.
bool & ScaleData()
Modify whether or not this PCA object will scale (by standard deviation) the data when PCA is perform...
bool ScaleData() const
Get whether or not this PCA object will scale (by standard deviation) the data when PCA is performed...