weka.classifiers
Class BVDecompose

java.lang.Object
  |
  +--weka.classifiers.BVDecompose
All Implemented Interfaces:
OptionHandler

public class BVDecompose
extends java.lang.Object
implements OptionHandler

Class for performing a Bias-Variance decomposition on any classifier using the method specified in:

R. Kohavi & D. Wolpert (1996), Bias plus variance decomposition for zero-one loss functions, in Proc. of the Thirteenth International Machine Learning Conference (ICML96) download postscript.

Valid options are:

-D
Turn on debugging output.

-W classname
Specify the full class name of a learner to perform the decomposition on (required).

-t filename
Set the arff file to use for the decomposition (required).

-T num
Specify the number of instances in the training pool (default 100).

-c num
Specify the index of the class attribute (default last).

-x num
Set the number of train iterations (default 50).

-s num
Set the seed for the dataset randomisation (default 1).

Options after -- are passed to the designated sub-learner.

Author:
Len Trigg (trigg@cs.waikato.ac.nz)

Field Summary
protected  double m_Bias
          The calculated bias (squared)
protected  Classifier m_Classifier
          An instantiated base classifier used for getting and testing options.
protected  java.lang.String[] m_ClassifierOptions
          The options to be passed to the base classifier.
protected  int m_ClassIndex
          The index of the class attribute
protected  java.lang.String m_DataFileName
          The name of the data file used for the decomposition
protected  boolean m_Debug
          Debugging mode, gives extra output if true
protected  double m_Error
          The error rate
protected  int m_Seed
          The random number seed
protected  double m_Sigma
          The calculated sigma (squared)
protected  int m_TrainIterations
          The number of train iterations
protected  int m_TrainPoolSize
          The number of instances used in the training pool
protected  double m_Variance
          The calculated variance
 
Constructor Summary
BVDecompose()
           
 
Method Summary
 void decompose()
          Carry out the bias-variance decomposition
 double getBias()
          Get the calculated bias squared
 Classifier getClassifier()
          Gets the name of the classifier being analysed
 int getClassIndex()
          Get the index (starting from 1) of the attribute used as the class.
 java.lang.String getDataFileName()
          Get the name of the data file used for the decomposition
 boolean getDebug()
          Gets whether debugging is turned on
 double getError()
          Get the calculated error rate
 java.lang.String[] getOptions()
          Gets the current settings of the CheckClassifier.
 int getSeed()
          Gets the random number seed
 double getSigma()
          Get the calculated sigma squared
 int getTrainIterations()
          Gets the maximum number of boost iterations
 int getTrainPoolSize()
          Get the number of instances in the training pool.
 double getVariance()
          Get the calculated variance
 java.util.Enumeration listOptions()
          Returns an enumeration describing the available options
static void main(java.lang.String[] args)
          Test method for this class
 void setClassifier(Classifier newClassifier)
          Set the classifiers being analysed
 void setClassIndex(int classIndex)
          Sets index of attribute to discretize on
 void setDataFileName(java.lang.String dataFileName)
          Sets the maximum number of boost iterations
 void setDebug(boolean debug)
          Sets debugging mode
 void setOptions(java.lang.String[] options)
          Parses a given list of options.
 void setSeed(int seed)
          Sets the random number seed
 void setTrainIterations(int trainIterations)
          Sets the maximum number of boost iterations
 void setTrainPoolSize(int numTrain)
          Set the number of instances in the training pool.
 java.lang.String toString()
          Returns description of the bias-variance decomposition results.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_Debug

protected boolean m_Debug
Debugging mode, gives extra output if true

m_Classifier

protected Classifier m_Classifier
An instantiated base classifier used for getting and testing options.

m_ClassifierOptions

protected java.lang.String[] m_ClassifierOptions
The options to be passed to the base classifier.

m_TrainIterations

protected int m_TrainIterations
The number of train iterations

m_DataFileName

protected java.lang.String m_DataFileName
The name of the data file used for the decomposition

m_ClassIndex

protected int m_ClassIndex
The index of the class attribute

m_Seed

protected int m_Seed
The random number seed

m_Bias

protected double m_Bias
The calculated bias (squared)

m_Variance

protected double m_Variance
The calculated variance

m_Sigma

protected double m_Sigma
The calculated sigma (squared)

m_Error

protected double m_Error
The error rate

m_TrainPoolSize

protected int m_TrainPoolSize
The number of instances used in the training pool
Constructor Detail

BVDecompose

public BVDecompose()
Method Detail

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:

-D
Turn on debugging output.

-W classname
Specify the full class name of a learner to perform the decomposition on (required).

-t filename
Set the arff file to use for the decomposition (required).

-T num
Specify the number of instances in the training pool (default 100).

-c num
Specify the index of the class attribute (default last).

-x num
Set the number of train iterations (default 50).

-s num
Set the seed for the dataset randomisation (default 1).

Options after -- are passed to the designated sub-learner.

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 CheckClassifier.
Specified by:
getOptions in interface OptionHandler
Returns:
an array of strings suitable for passing to setOptions

getTrainPoolSize

public int getTrainPoolSize()
Get the number of instances in the training pool.
Returns:
number of instances in the training pool.

setTrainPoolSize

public void setTrainPoolSize(int numTrain)
Set the number of instances in the training pool.
Parameters:
numTrain - number of instances in the training pool.

setClassifier

public void setClassifier(Classifier newClassifier)
Set the classifiers being analysed
Parameters:
newClassifier - the Classifier to use.

getClassifier

public Classifier getClassifier()
Gets the name of the classifier being analysed
Returns:
the classifier being analysed.

setDebug

public void setDebug(boolean debug)
Sets debugging mode
Parameters:
debug - true if debug output should be printed

getDebug

public boolean getDebug()
Gets whether debugging is turned on
Returns:
true if debugging output is on

setSeed

public void setSeed(int seed)
Sets the random number seed

getSeed

public int getSeed()
Gets the random number seed
Returns:
the random number seed

setTrainIterations

public void setTrainIterations(int trainIterations)
Sets the maximum number of boost iterations

getTrainIterations

public int getTrainIterations()
Gets the maximum number of boost iterations
Returns:
the maximum number of boost iterations

setDataFileName

public void setDataFileName(java.lang.String dataFileName)
Sets the maximum number of boost iterations

getDataFileName

public java.lang.String getDataFileName()
Get the name of the data file used for the decomposition
Returns:
the name of the data file

getClassIndex

public int getClassIndex()
Get the index (starting from 1) of the attribute used as the class.
Returns:
the index of the class attribute

setClassIndex

public void setClassIndex(int classIndex)
Sets index of attribute to discretize on
Parameters:
index - the index (starting from 1) of the class attribute

getBias

public double getBias()
Get the calculated bias squared
Returns:
the bias squared

getVariance

public double getVariance()
Get the calculated variance
Returns:
the variance

getSigma

public double getSigma()
Get the calculated sigma squared
Returns:
the sigma squared

getError

public double getError()
Get the calculated error rate
Returns:
the error rate

decompose

public void decompose()
               throws java.lang.Exception
Carry out the bias-variance decomposition
Throws:
java.lang.Exception - if the decomposition couldn't be carried out

toString

public java.lang.String toString()
Returns description of the bias-variance decomposition results.
Overrides:
toString in class java.lang.Object
Returns:
the bias-variance decomposition results as a string

main

public static void main(java.lang.String[] args)
Test method for this class
Parameters:
args - the command line arguments