weka.clusterers
Class DistributionMetaClusterer

java.lang.Object
  extended byweka.clusterers.Clusterer
      extended byweka.clusterers.DistributionClusterer
          extended byweka.clusterers.DistributionMetaClusterer
All Implemented Interfaces:
java.lang.Cloneable, OptionHandler, java.io.Serializable

public class DistributionMetaClusterer
extends DistributionClusterer
implements OptionHandler

Class for wrapping a Clusterer to make it return a distribution. Simply outputs a probabiltry of 1 for the chosen cluster and 0 for the others.

See Also:
Serialized Form

Constructor Summary
DistributionMetaClusterer()
          Default constructor.
DistributionMetaClusterer(Clusterer toWrap)
          Contructs a DistributionMetaClusterer wrapping a given Clusterer.
 
Method Summary
 void buildClusterer(Instances data)
          Builds a clusterer for a set of instances.
 double densityForInstance(Instance instance)
          Computes the density for a given instance.
 double[] distributionForInstance(Instance instance)
          Returns the cluster probability distribution for an instance.
 Clusterer getClusterer()
          Gets the clusterer being wrapped.
 java.lang.String[] getOptions()
          Gets the current settings of the clusterer.
 java.util.Enumeration listOptions()
          Returns an enumeration describing the available options..
static void main(java.lang.String[] argv)
          Main method for testing this class.
 int numberOfClusters()
          Returns the number of clusters.
 void setClusterer(Clusterer toWrap)
          Sets the clusterer to wrap.
 void setOptions(java.lang.String[] options)
          Parses a given list of options.
 java.lang.String toString()
          Returns a description of the clusterer.
 
Methods inherited from class weka.clusterers.DistributionClusterer
clusterInstance
 
Methods inherited from class weka.clusterers.Clusterer
forName, makeCopies
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DistributionMetaClusterer

public DistributionMetaClusterer()
Default constructor.


DistributionMetaClusterer

public DistributionMetaClusterer(Clusterer toWrap)
Contructs a DistributionMetaClusterer wrapping a given Clusterer.

Parameters:
toWrap - the clusterer to wrap around
Method Detail

buildClusterer

public void buildClusterer(Instances data)
                    throws java.lang.Exception
Builds a clusterer for a set of instances.

Specified by:
buildClusterer in class Clusterer
Parameters:
data - set of instances serving as training data
Throws:
java.lang.Exception - if the clusterer hasn't been set or something goes wrong

densityForInstance

public double densityForInstance(Instance instance)
                          throws java.lang.Exception
Computes the density for a given instance.

Specified by:
densityForInstance in class DistributionClusterer
Parameters:
instance - the instance to compute the density for
Returns:
the density.
Throws:
java.lang.Exception - if the density could not be computed successfully

distributionForInstance

public double[] distributionForInstance(Instance instance)
                                 throws java.lang.Exception
Returns the cluster probability distribution for an instance. Will simply have a probability of 1 for the chosen cluster and 0 for the others.

Specified by:
distributionForInstance in class DistributionClusterer
Parameters:
instance - the instance to be clustered
Returns:
the probability distribution
Throws:
java.lang.Exception - if distribution could not be computed successfully

numberOfClusters

public int numberOfClusters()
                     throws java.lang.Exception
Returns the number of clusters.

Specified by:
numberOfClusters in class Clusterer
Returns:
the number of clusters generated for a training dataset.
Throws:
java.lang.Exception - if number of clusters could not be returned successfully

toString

public java.lang.String toString()
Returns a description of the clusterer.

Returns:
a string containing a description of the clusterer

setClusterer

public void setClusterer(Clusterer toWrap)
Sets the clusterer to wrap.

Parameters:
toWrap - the clusterer

getClusterer

public Clusterer getClusterer()
Gets the clusterer being wrapped.

Returns:
the clusterer

listOptions

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

Specified by:
listOptions in interface OptionHandler
Returns:
an enumeration of all the available options.

setOptions

public void setOptions(java.lang.String[] options)
                throws java.lang.Exception
Parses a given list of options. Valid options are:

-W clusterer name
Clusterer to wrap. (required)

Specified by:
setOptions in interface OptionHandler
Parameters:
options - the list of options as an array of strings
Throws:
java.lang.Exception - if an option is not supported

getOptions

public java.lang.String[] getOptions()
Gets the current settings of the clusterer.

Specified by:
getOptions in interface OptionHandler
Returns:
an array of strings suitable for passing to setOptions()

main

public static void main(java.lang.String[] argv)
Main method for testing this class.

Parameters:
argv - the options