16 #ifndef MLPACK_METHODS_PCA_PCA_HPP 17 #define MLPACK_METHODS_PCA_PCA_HPP 33 template<
typename DecompositionPolicy = ExactSVDPolicy>
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);
151 #include "pca_impl.hpp" bool & ScaleData()
Modify whether or not this PCA object will scale (by standard deviation) the data when PCA is perform...
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.
void Apply(const arma::mat &data, arma::mat &transformedData, arma::vec &eigVal, arma::mat &eigvec)
Apply Principal Component Analysis to the provided data set.
PCAType< ExactSVDPolicy > PCA
3.0.0 TODO: break reverse-compatibility by changing PCAType to PCA.
DecompositionPolicy decomposition
Decomposition method used to perform principal components analysis.
void ScaleData(arma::mat ¢eredData)
Scaling the data is when we reduce the variance of each dimension to 1.
bool ScaleData() const
Get whether or not this PCA object will scale (by standard deviation) the data when PCA is performed...
bool scaleData
Whether or not the data will be scaled by standard deviation when PCA is performed.
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...