Vespucci  1.0.0
mlpackpcadata.cpp
Go to the documentation of this file.
2 
4  AnalysisResults(name, "mlpack PCA Results")
5 {
6 
7 }
8 
9 void MlpackPCAData::Apply(const mat &data, bool scale_data)
10 {
11  mlpack::pca::PCA pca_data(scale_data);
12  mat transformed_data, eigvec;
13  vec eigval, percent_variance;
14  try{
15  pca_data.Apply(data, transformed_data, eigval, eigvec);
16  }
17  catch(exception e){
18  throw std::runtime_error("MLPACKPCAData::Apply()");
19  }
20  double eigval_sum = sum(eigval);
21  percent_variance = eigval / eigval_sum;
22  percent_variance /= 0.01;
23 
24  AddMatrix("Projection", transformed_data, QStringList());
25  AddMatrix("Loadings", eigvec, QStringList());
26  AddMatrix("Eigenvalues", eigval, QStringList());
27  AddMatrix("Percent Variance", percent_variance, QStringList());
28 }
29 
void AddMatrix(const QString &key, const mat &value, QStringList column_headings=QStringList())
MlpackPCAData(QString name)
void Apply(const mat &data, bool scale_data)
The AnalysisResults class A container for a mat object that allows a mat to be copied to a heap-alloc...