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.

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

Constructors

 o SimpleKMeans
 public SimpleKMeans()

Methods

 o globalInfo
 public 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 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: Exception
if the clusterer has not been generated successfully
Overrides:
buildClusterer in class Clusterer
 o clusterInstance
 public int clusterInstance(Instance instance) throws 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: Exception
if instance could not be classified successfully
Overrides:
clusterInstance in class Clusterer
 o numberOfClusters
 public int numberOfClusters() throws Exception
Returns the number of clusters.

Returns:
the number of clusters generated for a training dataset.
Throws: Exception
if number of clusters could not be returned successfully
Overrides:
numberOfClusters in class Clusterer
 o listOptions
 public 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 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 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(String options[]) throws Exception
Parses a given list of options.

Parameters:
options - the list of options as an array of strings
Throws: Exception
if an option is not supported
 o getOptions
 public String[] getOptions()
Gets the current settings of SimpleKMeans

Returns:
an array of strings suitable for passing to setOptions()
 o toString
 public String toString()
return a string describing this clusterer

Returns:
a description of the clusterer as a string
Overrides:
toString in class Object
 o main
 public static void main(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