Specify random number seed.
- Version:
- $Revision: 1.6 $
- Author:
- Mark Hall (mhall@cs.waikato.ac.nz)
- See Also:
Clusterer
,
OptionHandler
,
Serialized Form
SimpleKMeans
public SimpleKMeans()
globalInfo
public String globalInfo()
- Returns a string describing this clusterer
- Returns:
- a description of the evaluator suitable for
displaying in the explorer/experimenter gui
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.
- Specified by:
buildClusterer
in class Clusterer
- Parameters:
data
- set of instances serving as training data
- Throws:
Exception
- if the clusterer has not been
generated successfully
clusterInstance
public int clusterInstance(Instance instance)
throws Exception
- Classifies a given instance.
- Specified by:
clusterInstance
in class Clusterer
- 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
numberOfClusters
public int numberOfClusters()
throws Exception
- Returns the number of clusters.
- Specified by:
numberOfClusters
in class Clusterer
- Returns:
- the number of clusters generated for a training dataset.
- Throws:
Exception
- if number of clusters could not be returned
successfully
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.
- Specified by:
listOptions
in interface OptionHandler
- Returns:
- an enumeration of all the available options
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
setNumClusters
public void setNumClusters(int n)
- set the number of clusters to generate
- Parameters:
n
- the number of clusters to generate
getNumClusters
public int getNumClusters()
- gets the number of clusters to generate
- Returns:
- the number of clusters to generate
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
setSeed
public void setSeed(int s)
- Set the random number seed
- Parameters:
s
- the seed
getSeed
public int getSeed()
- Get the random number seed
- Returns:
- the seed
setOptions
public void setOptions(String[] options)
throws Exception
- Parses a given list of options.
- Specified by:
setOptions
in interface OptionHandler
- Parameters:
options
- the list of options as an array of strings
- Throws:
Exception
- if an option is not supported
getOptions
public String[] getOptions()
- Gets the current settings of SimpleKMeans
- Specified by:
getOptions
in interface OptionHandler
- Returns:
- an array of strings suitable for passing to setOptions()
toString
public String toString()
- return a string describing this clusterer
- Overrides:
toString
in class Object
- Returns:
- a description of the clusterer as a string
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]