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

Class weka.clusterers.EM

java.lang.Object
   |
   +----weka.clusterers.Clusterer
           |
           +----weka.clusterers.DistributionClusterer
                   |
                   +----weka.clusterers.EM

public class EM
extends DistributionClusterer
implements OptionHandler
Simple EM (estimation maximisation) class.

EM assigns a probability distribution to each instance which indicates the probability of it belonging to each of the clusters. EM can decide how many clusters to create by cross validation, or you may specify apriori how many clusters to generate.

Valid options are:

-V
Verbose.

-N
-I
Terminate after this many iterations if EM has not converged.

-S
Specify random number seed.

Version:
$Revision: 1.6 $
Author:
Mark Hall (mhall@cs.waikato.ac.nz)

Constructor Index

 o EM()
Constructor.

Method Index

 o buildClusterer(Instances)
Classifies a given instance.
 o distributionForInstance(Instance)
Predicts the cluster memberships for a given instance.
 o getDebug()
Get debug mode
 o getMaxIterations()
Get the maximum number of iterations
 o getNumClusters()
Get the number of clusters
 o getOptions()
Gets the current settings of EM.
 o getSeed()
Get the random number seed
 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 setDebug(boolean)
Set debug mode - verbose output
 o setMaxIterations(int)
Set the maximum number of iterations to perform
 o setNumClusters(int)
Set the number of clusters (-1 to select by CV).
 o setOptions(String[])
Parses a given list of options.
 o setSeed(int)
Set the random number seed
 o toString()
Outputs the generated clusters into a string.

Constructors

 o EM
 public EM()
Constructor.

Methods

 o listOptions
 public Enumeration listOptions()
Returns an enumeration describing the available options.

Valid options are:

-V
Verbose.

-N
-I
Terminate after this many iterations if EM has not converged.

-S
Specify random number seed.

Returns:
an enumeration of all the available options
 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 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 setNumClusters
 public void setNumClusters(int n) throws Exception
Set the number of clusters (-1 to select by CV).

Parameters:
n - the number of clusters
Throws: Exception
if n is 0
 o getNumClusters
 public int getNumClusters()
Get the number of clusters

Returns:
the number of clusters.
 o setMaxIterations
 public void setMaxIterations(int i) throws Exception
Set the maximum number of iterations to perform

Parameters:
i - the number of iterations
Throws: Exception
if i is less than 1
 o getMaxIterations
 public int getMaxIterations()
Get the maximum number of iterations

Returns:
the number of iterations
 o setDebug
 public void setDebug(boolean v)
Set debug mode - verbose output

Parameters:
v - true for verbose output
 o getDebug
 public boolean getDebug()
Get debug mode

Returns:
true if debug mode is set
 o getOptions
 public String[] getOptions()
Gets the current settings of EM.

Returns:
an array of strings suitable for passing to setOptions()
 o toString
 public String toString()
Outputs the generated clusters into a string.

Overrides:
toString in class Object
 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 buildClusterer
 public void buildClusterer(Instances data) 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:
buildClusterer in class Clusterer
 o distributionForInstance
 public double[] distributionForInstance(Instance inst) throws Exception
Predicts the cluster memberships for a given instance.

Parameters:
data - set of test instances
instance - the instance to be assigned a cluster.
Returns:
an array containing the estimated membership probabilities of the test instance in each cluster (this should sum to at most 1)
Throws: Exception
if distribution could not be computed successfully
Overrides:
distributionForInstance in class DistributionClusterer
 o main
 public static void main(String argv[])
Main method for testing this class.

Parameters:
argv - should contain the following arguments:

-t training file [-T test file] [-N number of clusters] [-S random seed]


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