weka.clusterers
Class DistributionMetaClusterer

java.lang.Object
  |
  +--weka.clusterers.Clusterer
        |
        +--weka.clusterers.DistributionClusterer
              |
              +--weka.clusterers.DistributionMetaClusterer
All Implemented Interfaces:
java.lang.Cloneable, OptionHandler, java.io.Serializable

public class DistributionMetaClusterer
extends DistributionClusterer
implements OptionHandler

Class that wraps up a Clusterer and presents it as a DistributionClusterer for ease of programmatically handling Clusterers in general -- only the one predict method (distributionForInstance) need be worried about. The distributions produced by this clusterer place a probability of 1 on the class value predicted by the sub-clusterer.

Valid options are:

-W classname
Specify the full class name of a sub-clusterer (required).

Author:
Richard Littin (richard@intelligenesis.net)
See Also:
Serialized Form

Constructor Summary
DistributionMetaClusterer()
           
 
Method Summary
 void buildClusterer(Instances insts)
          Builds the clusterer.
 double densityForInstance(Instance inst)
          Returns the density for an instance.
 double[] distributionForInstance(Instance inst)
          Returns the distribution for an instance.
 Clusterer getClusterer()
          Get the clusterer used as the clusterer
 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 newClusterer)
          Set the base clusterer.
 void setOptions(java.lang.String[] options)
          Parses a given list of options.
 java.lang.String toString()
          Prints the clusterers.
 
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()
Method Detail

buildClusterer

public void buildClusterer(Instances insts)
                    throws java.lang.Exception
Builds the clusterer.
Overrides:
buildClusterer in class Clusterer
Parameters:
insts - the training data.
Throws:
java.lang.Exception - if a clusterer can't be built

distributionForInstance

public double[] distributionForInstance(Instance inst)
                                 throws java.lang.Exception
Returns the distribution for an instance.
Overrides:
distributionForInstance in class DistributionClusterer
Throws:
java.lang.Exception - if the distribution can't be computed successfully

densityForInstance

public double densityForInstance(Instance inst)
                          throws java.lang.Exception
Returns the density for an instance.
Overrides:
densityForInstance in class DistributionClusterer
Throws:
java.lang.Exception - if the distribution can't be computed successfully

numberOfClusters

public int numberOfClusters()
                     throws java.lang.Exception
Returns the number of clusters.
Overrides:
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()
Prints the clusterers.
Overrides:
toString in class java.lang.Object

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 classname
Specify the full class name of a learner as the basis for the multiclassclusterer (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

setClusterer

public void setClusterer(Clusterer newClusterer)
Set the base clusterer.
Parameters:
newClusterer - the Clusterer to use.

getClusterer

public Clusterer getClusterer()
Get the clusterer used as the clusterer
Returns:
the clusterer used as the clusterer

main

public static void main(java.lang.String[] argv)
Main method for testing this class.
Parameters:
argv - the options