weka.classifiers.meta
Class DistributionMetaClassifier

java.lang.Object
  extended byweka.classifiers.Classifier
      extended byweka.classifiers.DistributionClassifier
          extended byweka.classifiers.meta.DistributionMetaClassifier
All Implemented Interfaces:
java.lang.Cloneable, OptionHandler, java.io.Serializable

public class DistributionMetaClassifier
extends DistributionClassifier
implements OptionHandler

Class for wrapping a Classifier to make it return a distribution. Simply outputs a probabiltry of 1 for the predicted class and 0 for the others.

See Also:
Serialized Form

Constructor Summary
DistributionMetaClassifier()
          Default constructor.
DistributionMetaClassifier(Classifier toWrap)
          Contructs a DistributionMetaClassifier wrapping a given Classifier.
 
Method Summary
 void buildClassifier(Instances data)
          Builds a classifier for a set of instances.
 double[] distributionForInstance(Instance instance)
          Returns the class probability distribution for an instance.
 Classifier getClassifier()
          Gets the classifier being wrapped.
 java.lang.String[] getOptions()
          Gets the current settings of the classifier.
 java.util.Enumeration listOptions()
          Returns an enumeration describing the available options..
static void main(java.lang.String[] argv)
          Main method for testing this class.
 void setClassifier(Classifier toWrap)
          Sets the classifier to wrap.
 void setOptions(java.lang.String[] options)
          Parses a given list of options.
 java.lang.String toString()
          Returns a description of the classifier.
 
Methods inherited from class weka.classifiers.DistributionClassifier
calculateEntropy, calculateLabeledInstanceMargin, calculateMargin, classifyInstance
 
Methods inherited from class weka.classifiers.Classifier
forName, makeCopies
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DistributionMetaClassifier

public DistributionMetaClassifier()
Default constructor.


DistributionMetaClassifier

public DistributionMetaClassifier(Classifier toWrap)
Contructs a DistributionMetaClassifier wrapping a given Classifier.

Parameters:
toWrap - the classifier to wrap around
Method Detail

buildClassifier

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

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

distributionForInstance

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

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

toString

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

Returns:
a string containing a description of the classifier

setClassifier

public void setClassifier(Classifier toWrap)
Sets the classifier to wrap.

Parameters:
toWrap - the classifier

getClassifier

public Classifier getClassifier()
Gets the classifier being wrapped.

Returns:
the classifier

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 classifier name
Classifier 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 classifier.

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