org.apache.mahout.clustering
Class ClusterIterator

java.lang.Object
  extended by org.apache.mahout.clustering.ClusterIterator

public class ClusterIterator
extends Object

This is an experimental clustering iterator which works with a ClusteringPolicy and a prior ClusterClassifier which has been initialized with a set of models. To date, it has been tested with k-means and Dirichlet clustering. See examples DisplayKMeans and DisplayDirichlet which have been switched over to use it.


Constructor Summary
ClusterIterator(ClusteringPolicy policy)
           
 
Method Summary
 ClusterClassifier iterate(Iterable<Vector> data, ClusterClassifier classifier, int numIterations)
          Iterate over data using a prior-trained ClusterClassifier, for a number of iterations
static void iterateMR(org.apache.hadoop.fs.Path inPath, org.apache.hadoop.fs.Path priorPath, org.apache.hadoop.fs.Path outPath, int numIterations)
          Iterate over data using a prior-trained ClusterClassifier, for a number of iterations using a mapreduce implementation
 void iterateSeq(org.apache.hadoop.fs.Path inPath, org.apache.hadoop.fs.Path priorPath, org.apache.hadoop.fs.Path outPath, int numIterations)
          Iterate over data using a prior-trained ClusterClassifier, for a number of iterations using a sequential implementation
static ClusterClassifier readClassifier(org.apache.hadoop.fs.Path inPath)
           
static void writeClassifier(ClusterClassifier classifier, org.apache.hadoop.fs.Path outPath, String k)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClusterIterator

public ClusterIterator(ClusteringPolicy policy)
Method Detail

iterate

public ClusterClassifier iterate(Iterable<Vector> data,
                                 ClusterClassifier classifier,
                                 int numIterations)
Iterate over data using a prior-trained ClusterClassifier, for a number of iterations

Parameters:
data - a List<Vector> of input vectors
classifier - a prior ClusterClassifier
numIterations - the int number of iterations to perform
Returns:
the posterior ClusterClassifier

iterateSeq

public void iterateSeq(org.apache.hadoop.fs.Path inPath,
                       org.apache.hadoop.fs.Path priorPath,
                       org.apache.hadoop.fs.Path outPath,
                       int numIterations)
                throws IOException
Iterate over data using a prior-trained ClusterClassifier, for a number of iterations using a sequential implementation

Parameters:
inPath - a Path to input VectorWritables
priorPath - a Path to the prior classifier
outPath - a Path of output directory
numIterations - the int number of iterations to perform
Throws:
IOException

iterateMR

public static void iterateMR(org.apache.hadoop.fs.Path inPath,
                             org.apache.hadoop.fs.Path priorPath,
                             org.apache.hadoop.fs.Path outPath,
                             int numIterations)
                      throws IOException,
                             InterruptedException,
                             ClassNotFoundException
Iterate over data using a prior-trained ClusterClassifier, for a number of iterations using a mapreduce implementation

Parameters:
inPath - a Path to input VectorWritables
priorPath - a Path to the prior classifier
outPath - a Path of output directory
numIterations - the int number of iterations to perform
Throws:
IOException
InterruptedException
ClassNotFoundException

writeClassifier

public static void writeClassifier(ClusterClassifier classifier,
                                   org.apache.hadoop.fs.Path outPath,
                                   String k)
                            throws IOException
Throws:
IOException

readClassifier

public static ClusterClassifier readClassifier(org.apache.hadoop.fs.Path inPath)
                                        throws IOException
Throws:
IOException


Copyright © 2008-2012 The Apache Software Foundation. All Rights Reserved.