16#ifndef MLPACK_METHODS_PCA_PCA_HPP
17#define MLPACK_METHODS_PCA_PCA_HPP
32template<
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,
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;
148#include "pca_impl.hpp"
This class implements principal components analysis (PCA).
double Apply(arma::mat &data, const int newDimension)
This overload is here to make sure int gets casted right to size_t.
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.
void Apply(const arma::mat &data, arma::mat &transformedData, arma::vec &eigVal, arma::mat &eigvec)
Apply Principal Component Analysis to the provided data set.
double Apply(arma::mat &data, const size_t newDimension)
Use PCA for dimensionality reduction on the given dataset.
double Apply(arma::mat &data, const double varRetained)
Use PCA for dimensionality reduction on the given dataset.
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...
void Apply(const arma::mat &data, arma::mat &transformedData, arma::vec &eigVal)
Apply Principal Component Analysis to the provided data set.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.