messif.pivotselection
Class KMeansPivotChooser

java.lang.Object
  extended by messif.pivotselection.AbstractPivotChooser
      extended by messif.pivotselection.KMeansPivotChooser

public class KMeansPivotChooser
extends AbstractPivotChooser

This class uses the k-means algorithm adapted for metric spaces to cluster the objects


Nested Class Summary
protected  class KMeansPivotChooser.SelectClustroidThread
          Internal thread for selecting the "center" of a cluster.
 
Field Summary
protected  AbstractObjectList<LocalAbstractObject> initialPivots
          List of initial pivots
static int MAX_ITERATIONS
          Maximal number of iterations to let run
static float PIVOTS_DISTINCTION_THRESHOLD
          Threshold to consider 2 pivots the same
static int PIVOTS_SAMPLE_SIZE
          Size of the sample set to select a pivot from in each iteration of the k-means
 
Fields inherited from class messif.pivotselection.AbstractPivotChooser
counterBucketReadBuckets, counterObjectDistComp, counterPivotDistComp, counterPivotReadBuckets, preselectedPivots, sampleProviders
 
Constructor Summary
KMeansPivotChooser()
          Creates a new instance of KMeansPivotChooser with empty initial list of pivots.
KMeansPivotChooser(AbstractObjectList<LocalAbstractObject> initialPivots)
          Creates a new instance of KMeansPivotChooser.
 
Method Summary
 void printPivots(java.lang.String msg)
          Prints all pivots selected by this chooser.
protected  void selectPivot(int count, AbstractObjectIterator<? extends LocalAbstractObject> sampleSetIterator)
          This method only uses the preselected pivots as initial pivots for k-means and rewrites the pivots completely
 
Methods inherited from class messif.pivotselection.AbstractPivotChooser
addPivot, clear, deregisterSampleProvider, getLastPivot, getNextPivot, getPivot, getPivot, iterator, registerSampleProvider, removeLastPivot, selectPivot, selectPivot, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PIVOTS_SAMPLE_SIZE

public static final int PIVOTS_SAMPLE_SIZE
Size of the sample set to select a pivot from in each iteration of the k-means

See Also:
Constant Field Values

PIVOTS_DISTINCTION_THRESHOLD

public static final float PIVOTS_DISTINCTION_THRESHOLD
Threshold to consider 2 pivots the same

See Also:
Constant Field Values

MAX_ITERATIONS

public static final int MAX_ITERATIONS
Maximal number of iterations to let run

See Also:
Constant Field Values

initialPivots

protected AbstractObjectList<LocalAbstractObject> initialPivots
List of initial pivots

Constructor Detail

KMeansPivotChooser

public KMeansPivotChooser()
Creates a new instance of KMeansPivotChooser with empty initial list of pivots.


KMeansPivotChooser

public KMeansPivotChooser(AbstractObjectList<LocalAbstractObject> initialPivots)
Creates a new instance of KMeansPivotChooser.

Parameters:
initialPivots - the list of initial pivots
Method Detail

selectPivot

protected void selectPivot(int count,
                           AbstractObjectIterator<? extends LocalAbstractObject> sampleSetIterator)
This method only uses the preselected pivots as initial pivots for k-means and rewrites the pivots completely

Specified by:
selectPivot in class AbstractPivotChooser
Parameters:
count - Number of pivots to generate
sampleSetIterator - Iterator over the sample set of objects to choose new pivots from

printPivots

public void printPivots(java.lang.String msg)
Prints all pivots selected by this chooser. Pivots are printed to System.err.

Parameters:
msg - optional message printed before the pivots