infomat.algorithms.grouping
Class KMeans

java.lang.Object
  extended by infomat.algorithms.grouping.GroupingAlgorithm
      extended by infomat.algorithms.grouping.KMeans
All Implemented Interfaces:
NeedsISimilarity, HasProperties, UniqueIdentifiable

public class KMeans
extends GroupingAlgorithm
implements NeedsISimilarity

KMeans. An implementation of the K-Means clustering algorithm.


Field Summary
static int kmeansClusteringNumber
           
private  ISimilarity similarity
           
 
Fields inherited from class infomat.algorithms.grouping.GroupingAlgorithm
identifier, printGroupSizesInIterations, properties
 
Constructor Summary
KMeans()
           
KMeans(ISimilarity similarity)
           
KMeans(ISimilarity similarity, Properties properties)
           
KMeans(Properties properties)
           
 
Method Summary
 IObjectGrouping cluster(IObjectGroup iogroup)
          The clustering algorithm.
private  IObjectGrouping cluster(IObjectGroup iogroup, DenseISimilarity similarity)
          The clustering algorithm for a dense representation.
private  IObjectGrouping cluster(IObjectGroup iogroup, SparseISimilarity similarity)
          The clustering algorithm for a sparse representation.
private  IObjectGrouping clusterCartesian(IObjectGroup iogroup, SparseCartesianSimilarity similarity)
          The clustering algorithm for a sparse representation using the cartesian distance as the inverse for similarity.
 java.lang.String getAlgorithmName()
           
 Properties getDefaultProperties()
           
 java.lang.String getInfoString()
           
 Properties getProperties()
           
 java.lang.Object getPropertyValue(java.lang.String name)
           
 java.util.Vector getPropertyVector()
           
 ISimilarity getSimilarity()
           
 UniqueIdentifier getUniqueIdentifier()
           
private  java.util.Vector<IObjectGroup> init(IObjectGroup iogroup)
          Creating the initial partiton.
 IObjectGrouping oneIter(IObjectGrouping iogrouping, SparseISimilarity similarity)
          Implemented for the "Clustering" course of GSLT 2008.
 void setProperties(Properties properties)
           
 void setProperty(java.lang.String name, java.lang.Object value)
           
 void setSimilarity(ISimilarity similarity)
           
 void setUniqueIdentifier(UniqueIdentifier uniqueIdentifier)
           
 
Methods inherited from class infomat.algorithms.grouping.GroupingAlgorithm
printGroup, printGroupSizes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

kmeansClusteringNumber

public static int kmeansClusteringNumber

similarity

private ISimilarity similarity
Constructor Detail

KMeans

public KMeans()

KMeans

public KMeans(Properties properties)

KMeans

public KMeans(ISimilarity similarity)

KMeans

public KMeans(ISimilarity similarity,
              Properties properties)
Method Detail

getDefaultProperties

public Properties getDefaultProperties()
Specified by:
getDefaultProperties in interface HasProperties

setSimilarity

public void setSimilarity(ISimilarity similarity)
Specified by:
setSimilarity in interface NeedsISimilarity

getSimilarity

public ISimilarity getSimilarity()

cluster

public IObjectGrouping cluster(IObjectGroup iogroup)
The clustering algorithm.

Specified by:
cluster in class GroupingAlgorithm

cluster

private IObjectGrouping cluster(IObjectGroup iogroup,
                                SparseISimilarity similarity)
The clustering algorithm for a sparse representation.


clusterCartesian

private IObjectGrouping clusterCartesian(IObjectGroup iogroup,
                                         SparseCartesianSimilarity similarity)
The clustering algorithm for a sparse representation using the cartesian distance as the inverse for similarity. This is implemented as a special case since we gain very much in performance by precalculating the squared distances from origo for the centroids.


cluster

private IObjectGrouping cluster(IObjectGroup iogroup,
                                DenseISimilarity similarity)
The clustering algorithm for a dense representation.


init

private java.util.Vector<IObjectGroup> init(IObjectGroup iogroup)
Creating the initial partiton.


getInfoString

public java.lang.String getInfoString()
Specified by:
getInfoString in class GroupingAlgorithm

getAlgorithmName

public java.lang.String getAlgorithmName()
Specified by:
getAlgorithmName in class GroupingAlgorithm

getPropertyVector

public java.util.Vector getPropertyVector()
Specified by:
getPropertyVector in class GroupingAlgorithm

getPropertyValue

public java.lang.Object getPropertyValue(java.lang.String name)
Specified by:
getPropertyValue in interface HasProperties

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
                 throws PropertyNotFoundException
Specified by:
setProperty in interface HasProperties
Throws:
PropertyNotFoundException

getProperties

public Properties getProperties()
Specified by:
getProperties in interface HasProperties

setProperties

public void setProperties(Properties properties)
Specified by:
setProperties in interface HasProperties

getUniqueIdentifier

public UniqueIdentifier getUniqueIdentifier()
Specified by:
getUniqueIdentifier in interface UniqueIdentifiable

setUniqueIdentifier

public void setUniqueIdentifier(UniqueIdentifier uniqueIdentifier)
Specified by:
setUniqueIdentifier in interface UniqueIdentifiable

oneIter

public IObjectGrouping oneIter(IObjectGrouping iogrouping,
                               SparseISimilarity similarity)
Implemented for the "Clustering" course of GSLT 2008. Will not be kept up to date. Runs one iteration of the K-Means algorithm using the specified similarity, starting with the specified IObjectGrouping. Returns a new grouping representing the new state.