[mlpack-svn] r11629 - mlpack/trunk/src/mlpack/methods/pca
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Tue Feb 28 12:06:04 EST 2012
Author: rcurtin
Date: 2012-02-28 12:06:04 -0500 (Tue, 28 Feb 2012)
New Revision: 11629
Modified:
mlpack/trunk/src/mlpack/methods/pca/pca.hpp
mlpack/trunk/src/mlpack/methods/pca/pca_main.cpp
Log:
Add --scale and --nocenter options. Also center by default for PCA.
Modified: mlpack/trunk/src/mlpack/methods/pca/pca.hpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/pca/pca.hpp 2012-02-28 17:05:19 UTC (rev 11628)
+++ mlpack/trunk/src/mlpack/methods/pca/pca.hpp 2012-02-28 17:06:04 UTC (rev 11629)
@@ -16,7 +16,7 @@
class PCA
{
public:
- PCA(const bool centerData = false, const bool scaleData = false);
+ PCA(const bool centerData = true, const bool scaleData = false);
/**
* Apply Principal Component Analysis to the provided data set.
Modified: mlpack/trunk/src/mlpack/methods/pca/pca_main.cpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/pca/pca_main.cpp 2012-02-28 17:05:19 UTC (rev 11628)
+++ mlpack/trunk/src/mlpack/methods/pca/pca_main.cpp 2012-02-28 17:06:04 UTC (rev 11629)
@@ -25,6 +25,11 @@
PARAM_INT("new_dimensionality", "Desired dimensionality of output dataset. If "
"0, no dimensionality reduction is performed.", "d", 0);
+PARAM_FLAG("scale", "If set, the data will be scaled before running PCA, such "
+ "that the variance of each feature is 1.", "s");
+PARAM_FLAG("nocenter", "If set, the data will NOT be centered before performing"
+ " PCA.", "N");
+
int main(int argc, char** argv)
{
// Parse commandline.
@@ -49,8 +54,12 @@
}
}
+ // Get the options for running PCA.
+ const size_t scale = CLI::HasParam("scale");
+ const size_t center = !CLI::HasParam("nocenter");
+
// Perform PCA.
- PCA p;
+ PCA p(center, scale);
Log::Info << "Performing PCA on dataset..." << endl;
p.Apply(dataset, newDimension);
More information about the mlpack-svn
mailing list