12 #ifndef MLPACK_CORE_DATA_PCA_WHITENING_SCALE_HPP    13 #define MLPACK_CORE_DATA_PCA_WHITENING_SCALE_HPP    61       throw std::runtime_error(
"Regularization parameter is not correct");
    70   template<
typename MatType>
    71   void Fit(
const MatType& input)
    73     itemMean = arma::mean(input, 1);
    76         input.each_col() - itemMean));
    77     eigenValues += epsilon;
    86   template<
typename MatType>
    87   void Transform(
const MatType& input, MatType& output)
    89     if (eigenValues.is_empty() || eigenVectors.is_empty())
    91       throw std::runtime_error(
"Call Fit() before Transform(), please"    92           " refer to the documentation.");
    94     output.copy_size(input);
    95     output = (input.each_col() - itemMean);
    96     output = arma::diagmat(1.0 / (arma::sqrt(eigenValues))) * eigenVectors.t()
   106   template<
typename MatType>
   109     output = arma::diagmat(arma::sqrt(eigenValues)) * inv(eigenVectors.t())
   111     output = (output.each_col() + itemMean);
   115   const arma::vec& 
ItemMean()
 const { 
return itemMean; }
   121   const double& 
Epsilon()
 const { 
return epsilon; }
   123   template<
typename Archive>
   126     ar(CEREAL_NVP(eigenValues));
   127     ar(CEREAL_NVP(eigenVectors));
   128     ar(CEREAL_NVP(itemMean));
   129     ar(CEREAL_NVP(epsilon));
   136   arma::mat eigenVectors;
   140   arma::vec eigenValues;
 Linear algebra utility functions, generally performed on matrices or vectors. 
 
The core includes that mlpack expects; standard C++ includes and Armadillo. 
 
void serialize(Archive &ar, const uint32_t)
 
arma::Mat< eT > ColumnCovariance(const arma::Mat< eT > &A, const size_t norm_type=0)
 
const arma::vec & ItemMean() const
Get the mean row vector. 
 
void Fit(const MatType &input)
Function to fit features, to find out the min max and scale. 
 
A simple PCAWhitening class. 
 
const arma::vec & EigenValues() const
Get the eigenvalues vector. 
 
void InverseTransform(const MatType &input, MatType &output)
Function to retrieve original dataset. 
 
const double & Epsilon() const
Get the regularization parameter. 
 
PCAWhitening(double eps=0.00005)
A constructor to set the regularization parameter. 
 
const arma::mat & EigenVectors() const
Get the eigenvector. 
 
void Transform(const MatType &input, MatType &output)
Function for PCA whitening.