All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home

Class weka.clusterers.SimpleKMeans

java.lang.Object
    |
    +----weka.clusterers.Clusterer
            |
            +----weka.clusterers.SimpleKMeans

public class SimpleKMeans
extends Clusterer
implements OptionHandler
Simple k means clustering class. Valid options are:

-N
Specify the number of clusters to generate.

-S
Specify random number seed.

Version:
$Revision: 1.6 $
Author:
Mark Hall (mhall@cs.waikato.ac.nz)
See Also:
Clusterer, OptionHandler

Constructor Index

 o SimpleKMeans()
 

Method Index

 o buildClusterer(Instances)
Generates a clusterer.
 o clusterInstance(Instance)
Classifies a given instance.
 o getNumClusters()
gets the number of clusters to generate
 o getOptions()
Gets the current settings of SimpleKMeans
 o getSeed()
Get the random number seed
 o globalInfo()
Returns a string describing this clusterer
 o listOptions()
Returns an enumeration describing the available options.
 o main(String[])
Main method for testing this class.
 o numberOfClusters()
Returns the number of clusters.
 o numClustersTipText()
Returns the tip text for this property
 o seedTipText()
Returns the tip text for this property
 o setNumClusters(int)
set the number of clusters to generate
 o setOptions(String[])
Parses a given list of options.
 o setSeed(int)
Set the random number seed
 o toString()
return a string describing this clusterer

Constructor Detail

 o SimpleKMeans
public SimpleKMeans()

Method Detail

 o globalInfo
public java.lang.String globalInfo()
          Returns a string describing this clusterer
Returns:
a description of the evaluator suitable for displaying in the explorer/experimenter gui
 o buildClusterer
public void buildClusterer(Instances data) throws java.lang.Exception
          Generates a clusterer. Has to initialize all fields of the clusterer that are not being set via options.
Parameters:
data - set of instances serving as training data
Throws:
java.lang.Exception - if the clusterer has not been generated successfully
Overrides:
buildClusterer in class Clusterer
 o clusterInstance
public int clusterInstance(Instance instance) throws java.lang.Exception
          Classifies a given instance.
Parameters:
instance - the instance to be assigned to a cluster
Returns:
the number of the assigned cluster as an interger if the class is enumerated, otherwise the predicted value
Throws:
java.lang.Exception - if instance could not be classified successfully
Overrides:
clusterInstance in class Clusterer
 o numberOfClusters
public int numberOfClusters() throws java.lang.Exception
          Returns the number of clusters.
Returns:
the number of clusters generated for a training dataset.
Throws:
java.lang.Exception - if number of clusters could not be returned successfully
Overrides:
numberOfClusters in class Clusterer
 o listOptions
public java.util.Enumeration listOptions()
          Returns an enumeration describing the available options.

Valid options are:

-N
Specify the number of clusters to generate. If omitted, EM will use cross validation to select the number of clusters automatically.

-S
Specify random number seed.

Returns:
an enumeration of all the available options
 o numClustersTipText
public java.lang.String numClustersTipText()
          Returns the tip text for this property
Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui
 o setNumClusters
public void setNumClusters(int n)
          set the number of clusters to generate
Parameters:
n - the number of clusters to generate
 o getNumClusters
public int getNumClusters()
          gets the number of clusters to generate
Returns:
the number of clusters to generate
 o seedTipText
public java.lang.String seedTipText()
          Returns the tip text for this property
Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui
 o setSeed
public void setSeed(int s)
          Set the random number seed
Parameters:
s - the seed
 o getSeed
public int getSeed()
          Get the random number seed
Returns:
the seed
 o setOptions
public void setOptions(java.lang.String options[]) throws java.lang.Exception
          Parses a given list of options.
Parameters:
options - the list of options as an array of strings
Throws:
java.lang.Exception - if an option is not supported
 o getOptions
public java.lang.String[] getOptions()
          Gets the current settings of SimpleKMeans
Returns:
an array of strings suitable for passing to setOptions()
 o toString
public java.lang.String toString()
          return a string describing this clusterer
Returns:
a description of the clusterer as a string
Overrides:
toString in class java.lang.Object
 o main
public static void main(java.lang.String argv[])
          Main method for testing this class.
Parameters:
argv - should contain the following arguments:

-t training file [-N number of clusters]


All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home