weka.classifiers
Class MultiClassClassifier

java.lang.Object
  |
  +--weka.classifiers.Classifier
        |
        +--weka.classifiers.DistributionClassifier
              |
              +--weka.classifiers.MultiClassClassifier
All Implemented Interfaces:
java.lang.Cloneable, OptionHandler, java.io.Serializable

public class MultiClassClassifier
extends DistributionClassifier
implements OptionHandler

Class for handling multi-class datasets with 2-class distribution classifiers.

Valid options are:

-E num
Sets the error-correction mode. Valid values are 0 (no correction), 1 (random codes), and 2 (exhaustive code). (default 0)

-R num
Sets the multiplier when using random codes. (default 2.0)

-W classname
Specify the full class name of a classifier as the basis for the multi-class classifier (required).

Author:
Eibe Frank (eibe@cs.waikato.ac.nz), Len Trigg (len@webmind.com)
See Also:
Serialized Form

Field Summary
static int ERROR_EXHAUSTIVE
           
static int ERROR_NONE
          The error correction modes
static int ERROR_RANDOM
           
static Tag[] TAGS_ERROR
           
 
Constructor Summary
MultiClassClassifier()
           
 
Method Summary
 void buildClassifier(Instances insts)
          Builds the classifiers.
 java.lang.String distributionClassifierTipText()
           
 double[] distributionForInstance(Instance inst)
          Returns the distribution for an instance.
 java.lang.String errorCorrectionModeTipText()
           
 DistributionClassifier getDistributionClassifier()
          Get the classifier used as the classifier
 SelectedTag getErrorCorrectionMode()
          Gets the error correction mode used.
 java.lang.String[] getOptions()
          Gets the current settings of the Classifier.
 double getRandomWidthFactor()
          Gets the multiplier when generating random codes.
 java.lang.String globalInfo()
           
 java.util.Enumeration listOptions()
          Returns an enumeration describing the available options
static void main(java.lang.String[] argv)
          Main method for testing this class.
 java.lang.String randomWidthFactorTipText()
           
 void setDistributionClassifier(DistributionClassifier newClassifier)
          Set the base classifier.
 void setErrorCorrectionMode(SelectedTag newMethod)
          Sets the error correction mode used.
 void setOptions(java.lang.String[] options)
          Parses a given list of options.
 void setRandomWidthFactor(double newRandomWidthFactor)
          Sets the multiplier when generating random codes.
 java.lang.String toString()
          Prints the classifiers.
 
Methods inherited from class weka.classifiers.DistributionClassifier
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
 

Field Detail

ERROR_NONE

public static final int ERROR_NONE
The error correction modes

ERROR_RANDOM

public static final int ERROR_RANDOM

ERROR_EXHAUSTIVE

public static final int ERROR_EXHAUSTIVE

TAGS_ERROR

public static final Tag[] TAGS_ERROR
Constructor Detail

MultiClassClassifier

public MultiClassClassifier()
Method Detail

buildClassifier

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

distributionForInstance

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

toString

public java.lang.String toString()
Prints the classifiers.
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:

-E num
Sets the error-correction mode. Valid values are 0 (no correction), 1 (random codes), and 2 (exhaustive code). (default 0)

-R num
Sets the multiplier when using random codes. (default 2.0)

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

globalInfo

public java.lang.String globalInfo()
Returns:
a description of the classifier suitable for displaying in the explorer/experimenter gui

randomWidthFactorTipText

public java.lang.String randomWidthFactorTipText()
Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

getRandomWidthFactor

public double getRandomWidthFactor()
Gets the multiplier when generating random codes. Will generate numClasses * m_RandomWidthFactor codes.
Returns:
the width multiplier

setRandomWidthFactor

public void setRandomWidthFactor(double newRandomWidthFactor)
Sets the multiplier when generating random codes. Will generate numClasses * m_RandomWidthFactor codes.
Parameters:
newRandomWidthFactor - the new width multiplier

errorCorrectionModeTipText

public java.lang.String errorCorrectionModeTipText()
Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

getErrorCorrectionMode

public SelectedTag getErrorCorrectionMode()
Gets the error correction mode used. Will be one of ERROR_NONE, ERROR_RANDOM, or ERROR_EXHAUSTIVE.
Returns:
the current error correction mode.

setErrorCorrectionMode

public void setErrorCorrectionMode(SelectedTag newMethod)
Sets the error correction mode used. Will be one of ERROR_NONE, ERROR_RANDOM, or ERROR_EXHAUSTIVE.
Parameters:
newMethod - the new error correction mode.

distributionClassifierTipText

public java.lang.String distributionClassifierTipText()
Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

setDistributionClassifier

public void setDistributionClassifier(DistributionClassifier newClassifier)
Set the base classifier.
Parameters:
newClassifier - the Classifier to use.

getDistributionClassifier

public DistributionClassifier getDistributionClassifier()
Get the classifier used as the classifier
Returns:
the classifier used as the classifier

main

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