Author: squinn
Date: Tue Mar 12 19:03:55 2013
New Revision: 1455669

URL: http://svn.apache.org/r1455669
Log:
Added SSVD power iteration parameter to spectral kmeans cli. Updated the 
parameter names to match those in the SSVDcli.

Modified:
    
mahout/trunk/core/src/main/java/org/apache/mahout/clustering/spectral/kmeans/SpectralKMeansDriver.java

Modified: 
mahout/trunk/core/src/main/java/org/apache/mahout/clustering/spectral/kmeans/SpectralKMeansDriver.java
URL: 
http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/spectral/kmeans/SpectralKMeansDriver.java?rev=1455669&r1=1455668&r2=1455669&view=diff
==============================================================================
--- 
mahout/trunk/core/src/main/java/org/apache/mahout/clustering/spectral/kmeans/SpectralKMeansDriver.java
 (original)
+++ 
mahout/trunk/core/src/main/java/org/apache/mahout/clustering/spectral/kmeans/SpectralKMeansDriver.java
 Tue Mar 12 19:03:55 2013
@@ -54,6 +54,7 @@ public class SpectralKMeansDriver extend
        public static final int REDUCERS = 10;
        public static final int BLOCKHEIGHT = 30000;
        public static final int OVERSAMPLING = 15;
+       public static final int POWERITERS = 0;
 
        public static void main(String[] args) throws Exception {
                ToolRunner.run(new SpectralKMeansDriver(), args);
@@ -73,9 +74,10 @@ public class SpectralKMeansDriver extend
                addOption(DefaultOptionCreator.maxIterationsOption().create());
                addOption(DefaultOptionCreator.overwriteOption().create());
                addFlag("usessvd", "ssvd", "Uses SSVD as the eigensolver. 
Default is the Lanczos solver.");
-               addOption("ssvdreducers", "r", "Number of reducers for SSVD", 
String.valueOf(REDUCERS));
-               addOption("ssvdblockheight", "h", "Block height for SSVD", 
String.valueOf(BLOCKHEIGHT));
-               addOption("ssvdoversampling", "p", "Oversampling parameter for 
SSVD", String.valueOf(OVERSAMPLING));
+               addOption("reduceTasks", "t", "Number of reducers for SSVD", 
String.valueOf(REDUCERS));
+               addOption("outerProdBlockHeight", "oh", "Block height of outer 
products for SSVD", String.valueOf(BLOCKHEIGHT));
+               addOption("oversampling", "p", "Oversampling parameter for 
SSVD", String.valueOf(OVERSAMPLING));
+               addOption("powerIter", "q", "Additional power iterations for 
SSVD", String.valueOf(POWERITERS));
                
                Map<String, List<String>> parsedArgs = parseArguments(arg0);
                if (parsedArgs == null) {
@@ -97,11 +99,12 @@ public class SpectralKMeansDriver extend
                Path tempdir = new Path(getOption("tempDir"));
                boolean ssvd = parsedArgs.containsKey("--usessvd");
                if (ssvd) {
-                   int reducers = Integer.parseInt(getOption("ssvdreducers"));
-                   int blockheight = 
Integer.parseInt(getOption("ssvdblockheight"));
+                   int reducers = Integer.parseInt(getOption("reduceTasks"));
+                   int blockheight = 
Integer.parseInt(getOption("outerProdBlockHeight"));
                    int oversampling = 
Integer.parseInt(getOption("oversampling"));
+                   int poweriters = Integer.parseInt(getOption("powerIter"));
                    run(conf, input, output, numDims, clusters, measure, 
convergenceDelta,
-                           maxIterations, tempdir, true, reducers, 
blockheight, oversampling);
+                           maxIterations, tempdir, true, reducers, 
blockheight, oversampling, poweriters);
                } else {
                    run(conf, input, output, numDims, clusters, measure, 
convergenceDelta,
                            maxIterations, tempdir, false);
@@ -122,7 +125,7 @@ public class SpectralKMeansDriver extend
                Path tempDir,
                boolean ssvd) throws IOException, InterruptedException, 
ClassNotFoundException {
            run(conf, input, output, numDims, clusters, measure, 
convergenceDelta,
-                   maxIterations, tempDir, ssvd, REDUCERS, BLOCKHEIGHT, 
OVERSAMPLING);
+                   maxIterations, tempDir, ssvd, REDUCERS, BLOCKHEIGHT, 
OVERSAMPLING, POWERITERS);
        }
 
   /**
@@ -138,6 +141,10 @@ public class SpectralKMeansDriver extend
    * @param maxIterations the int maximum number of iterations for the k-Means 
calculations
    * @param tempDir Temporary directory for intermediate calculations
    * @param ssvd Flag to indicate the eigensolver to use
+   * @param numReducers
+   * @param blockHeight
+   * @param oversampling
+   * @param poweriters
    */
        public static void run(
                  Configuration conf,
@@ -152,7 +159,8 @@ public class SpectralKMeansDriver extend
                  boolean ssvd,
                  int numReducers,
                  int blockHeight,
-                 int oversampling)
+                 int oversampling,
+                 int poweriters)
                                  throws IOException, InterruptedException, 
ClassNotFoundException {
     
                Path outputCalc = new Path(tempDir, "calculations");
@@ -200,7 +208,7 @@ public class SpectralKMeansDriver extend
                        solveIt.setComputeV(false); 
                        solveIt.setComputeU(true);
                        solveIt.setOverwrite(true);
-                       solveIt.setQ(0);
+                       solveIt.setQ(poweriters);
                        //solveIt.setBroadcast(false);
                        solveIt.run();
                        data = new Path(solveIt.getUPath());


Reply via email to