[mlpack-git] master: Parameter unification; add comment about PCAType class will be changed to have the name PCA in mlpack 3.0.0. (e7b9b04)

gitdub at mlpack.org gitdub at mlpack.org
Wed Jul 6 15:30:09 EDT 2016


Repository : https://github.com/mlpack/mlpack
On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/98babfc774bce91170df994763b670b9abd20917...e7b9b042d1d6e2d9895d5fa141e9c135b2d2ea57

>---------------------------------------------------------------

commit e7b9b042d1d6e2d9895d5fa141e9c135b2d2ea57
Author: Marcus Edel <marcus.edel at fu-berlin.de>
Date:   Wed Jul 6 14:19:03 2016 +0200

    Parameter unification; add comment about PCAType class will be changed to have the name PCA in mlpack 3.0.0.


>---------------------------------------------------------------

e7b9b042d1d6e2d9895d5fa141e9c135b2d2ea57
 src/mlpack/methods/pca/pca.hpp      |  5 +++--
 src/mlpack/methods/pca/pca_impl.hpp | 22 +++++++++++-----------
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/src/mlpack/methods/pca/pca.hpp b/src/mlpack/methods/pca/pca.hpp
index 41c7517..62b5475 100644
--- a/src/mlpack/methods/pca/pca.hpp
+++ b/src/mlpack/methods/pca/pca.hpp
@@ -22,7 +22,8 @@ namespace pca {
  * common, widely-used technique that is often used for either dimensionality
  * reduction or transforming data into a better basis.  Further information on
  * PCA can be found in almost any statistics or machine learning textbook, and
- * all over the internet.
+ * all over the internet. Note this class will be changed to have the name PCA
+ * in mlpack 3.0.0
  */
 template<typename DecompositionPolicy = ExactSVDPolicy>
 class PCAType
@@ -48,7 +49,7 @@ class PCAType
    */
   void Apply(const arma::mat& data,
              arma::mat& transformedData,
-             arma::vec& eigval,
+             arma::vec& eigVal,
              arma::mat& eigvec);
 
   /**
diff --git a/src/mlpack/methods/pca/pca_impl.hpp b/src/mlpack/methods/pca/pca_impl.hpp
index 9e3a89c..9f963b2 100644
--- a/src/mlpack/methods/pca/pca_impl.hpp
+++ b/src/mlpack/methods/pca/pca_impl.hpp
@@ -1,5 +1,5 @@
 /**
- * @file pca.cpp
+ * @file pca_impl.hpp
  * @author Ajinkya Kale
  * @author Ryan Curtin
  * @author Marcus Edel
@@ -32,13 +32,13 @@ PCAType<DecompositionPolicy>::PCAType(const bool scaleData,
  * @param data - Data matrix
  * @param transformedData - Data with PCA applied
  * @param eigVal - contains eigen values in a column vector
- * @param coeff - PCA Loadings/Coeffs/EigenVectors
+ * @param eigvec - PCA Loadings/Coeffs/EigenVectors
  */
 template<typename DecompositionPolicy>
 void PCAType<DecompositionPolicy>::Apply(const arma::mat& data,
                                          arma::mat& transformedData,
                                          arma::vec& eigVal,
-                                         arma::mat& coeff)
+                                         arma::mat& eigvec)
 {
   Timer::Start("pca");
 
@@ -49,7 +49,7 @@ void PCAType<DecompositionPolicy>::Apply(const arma::mat& data,
   // Scale the data if the user ask for.
   ScaleData(centeredData);
 
-  decomposition.Apply(data, centeredData, transformedData, eigVal, coeff,
+  decomposition.Apply(data, centeredData, transformedData, eigVal, eigvec,
       data.n_rows);
 
   Timer::Stop("pca");
@@ -67,8 +67,8 @@ void PCAType<DecompositionPolicy>::Apply(const arma::mat& data,
                                          arma::mat& transformedData,
                                          arma::vec& eigVal)
 {
-  arma::mat coeffs;
-  Apply(data, transformedData, eigVal, coeffs);
+  arma::mat eigvec;
+  Apply(data, transformedData, eigVal, eigvec);
 }
 
 /**
@@ -95,7 +95,7 @@ double PCAType<DecompositionPolicy>::Apply(arma::mat& data,
         << "be greater than the existing dimensionality of the data ("
         << data.n_rows << ")!" << endl;
 
-  arma::mat coeffs;
+  arma::mat eigvec;
   arma::vec eigVal;
 
   Timer::Start("pca");
@@ -107,9 +107,9 @@ double PCAType<DecompositionPolicy>::Apply(arma::mat& data,
   // Scale the data if the user ask for.
   ScaleData(centeredData);
 
-  decomposition.Apply(data, centeredData, data, eigVal, coeffs, newDimension);
+  decomposition.Apply(data, centeredData, data, eigVal, eigvec, newDimension);
 
-  if (newDimension < coeffs.n_rows)
+  if (newDimension < eigvec.n_rows)
     // Drop unnecessary rows.
     data.shed_rows(newDimension, data.n_rows - 1);
 
@@ -145,10 +145,10 @@ double PCAType<DecompositionPolicy>::Apply(arma::mat& data,
     Log::Fatal << "PCA::Apply(): varRetained (" << varRetained << ") should be "
         << "less than or equal to 1." << endl;
 
-  arma::mat coeffs;
+  arma::mat eigvec;
   arma::vec eigVal;
 
-  Apply(data, data, eigVal, coeffs);
+  Apply(data, data, eigVal, eigvec);
 
   // Calculate the dimension we should keep.
   size_t newDimension = 0;




More information about the mlpack-git mailing list