weka.attributeSelection
Class OneRAttributeEval

java.lang.Object
  extended byweka.attributeSelection.ASEvaluation
      extended byweka.attributeSelection.AttributeEvaluator
          extended byweka.attributeSelection.OneRAttributeEval
All Implemented Interfaces:
OptionHandler, java.io.Serializable

public class OneRAttributeEval
extends AttributeEvaluator
implements OptionHandler

Class for Evaluating attributes individually by using the OneR classifier.

-S
Set the seed for cross validation (default = 1).

-F
Set the number of folds for cross validation (default = 10).

-B
Set the minimum number of objects per bucket (passed on to OneR, default = 6).

-D
Use the training data to evaluate attributes rather than cross validation.

Version:
$Revision: 1.14 $
Author:
Mark Hall (mhall@cs.waikato.ac.nz)
See Also:
Serialized Form

Field Summary
private  int m_classIndex
          The class index
private  boolean m_evalUsingTrainingData
          Use training data to evaluate merit rather than x-val
private  int m_folds
          Number of folds for cross validation
private  int m_minBucketSize
          Passed on to OneR
private  int m_numAttribs
          The number of attributes
private  int m_numInstances
          The number of instances
private  int m_randomSeed
          Random number seed
private  Instances m_trainInstances
          The training instances
 
Constructor Summary
OneRAttributeEval()
          Constructor
 
Method Summary
 void buildEvaluator(Instances data)
          Initializes a OneRAttribute attribute evaluator.
 double evaluateAttribute(int attribute)
          evaluates an individual attribute by measuring the amount of information gained about the class given the attribute.
 java.lang.String evalUsingTrainingDataTipText()
          Returns a string for this option suitable for display in the gui as a tip text
 java.lang.String foldsTipText()
          Returns a string for this option suitable for display in the gui as a tip text
 boolean getEvalUsingTrainingData()
          Returns true if the training data is to be used for evaluation
 int getFolds()
          Get the number of folds used for cross validation
 int getMinimumBucketSize()
          Get the minimum bucket size used by oneR
 java.lang.String[] getOptions()
          Gets the current option settings for the OptionHandler.
 int getSeed()
          Get the random number seed
 java.lang.String globalInfo()
          Returns a string describing this attribute evaluator
 java.util.Enumeration listOptions()
          Returns an enumeration describing the available options.
static void main(java.lang.String[] args)
          Main method for testing this class.
 java.lang.String minimumBucketSizeTipText()
          Returns a string for this option suitable for display in the gui as a tip text
protected  void resetOptions()
          rests to defaults.
 java.lang.String seedTipText()
          Returns a string for this option suitable for display in the gui as a tip text
 void setEvalUsingTrainingData(boolean e)
          Use the training data to evaluate attributes rather than cross validation
 void setFolds(int folds)
          Set the number of folds to use for cross validation
 void setMinimumBucketSize(int minB)
          Set the minumum bucket size used by OneR
 void setOptions(java.lang.String[] options)
          Parses a given list of options.
 void setSeed(int seed)
          Set the random number seed for cross validation
 java.lang.String toString()
          Return a description of the evaluator
 
Methods inherited from class weka.attributeSelection.ASEvaluation
forName, makeCopies, postProcess
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_trainInstances

private Instances m_trainInstances
The training instances


m_classIndex

private int m_classIndex
The class index


m_numAttribs

private int m_numAttribs
The number of attributes


m_numInstances

private int m_numInstances
The number of instances


m_randomSeed

private int m_randomSeed
Random number seed


m_folds

private int m_folds
Number of folds for cross validation


m_evalUsingTrainingData

private boolean m_evalUsingTrainingData
Use training data to evaluate merit rather than x-val


m_minBucketSize

private int m_minBucketSize
Passed on to OneR

Constructor Detail

OneRAttributeEval

public OneRAttributeEval()
Constructor

Method Detail

globalInfo

public java.lang.String globalInfo()
Returns a string describing this attribute evaluator

Returns:
a description of the evaluator suitable for displaying in the explorer/experimenter gui

seedTipText

public java.lang.String seedTipText()
Returns a string for this option suitable for display in the gui as a tip text

Returns:
a string describing this option

setSeed

public void setSeed(int seed)
Set the random number seed for cross validation

Parameters:
seed - the seed to use

getSeed

public int getSeed()
Get the random number seed

Returns:
an int value

foldsTipText

public java.lang.String foldsTipText()
Returns a string for this option suitable for display in the gui as a tip text

Returns:
a string describing this option

setFolds

public void setFolds(int folds)
Set the number of folds to use for cross validation

Parameters:
folds - the number of folds

getFolds

public int getFolds()
Get the number of folds used for cross validation

Returns:
the number of folds

evalUsingTrainingDataTipText

public java.lang.String evalUsingTrainingDataTipText()
Returns a string for this option suitable for display in the gui as a tip text

Returns:
a string describing this option

setEvalUsingTrainingData

public void setEvalUsingTrainingData(boolean e)
Use the training data to evaluate attributes rather than cross validation

Parameters:
e - true if training data is to be used for evaluation

minimumBucketSizeTipText

public java.lang.String minimumBucketSizeTipText()
Returns a string for this option suitable for display in the gui as a tip text

Returns:
a string describing this option

setMinimumBucketSize

public void setMinimumBucketSize(int minB)
Set the minumum bucket size used by OneR

Parameters:
minB - the minimum bucket size to use

getMinimumBucketSize

public int getMinimumBucketSize()
Get the minimum bucket size used by oneR

Returns:
the minimum bucket size used

getEvalUsingTrainingData

public boolean getEvalUsingTrainingData()
Returns true if the training data is to be used for evaluation

Returns:
true if training data is to be used for evaluation

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:

-S
Set the seed for cross validation (default = 1).

-F
Set the number of folds for cross validation (default = 10).

-B
Set the minimum number of objects per bucket (passed on to OneR, default = 6).

-D
Use the training data to evaluate attributes rather than cross validation.

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()
Description copied from interface: OptionHandler
Gets the current option settings for the OptionHandler.

Specified by:
getOptions in interface OptionHandler
Returns:
the list of current option settings as an array of strings

buildEvaluator

public void buildEvaluator(Instances data)
                    throws java.lang.Exception
Initializes a OneRAttribute attribute evaluator. Discretizes all attributes that are numeric.

Specified by:
buildEvaluator in class ASEvaluation
Parameters:
data - set of instances serving as training data
Throws:
java.lang.Exception - if the evaluator has not been generated successfully

resetOptions

protected void resetOptions()
rests to defaults.


evaluateAttribute

public double evaluateAttribute(int attribute)
                         throws java.lang.Exception
evaluates an individual attribute by measuring the amount of information gained about the class given the attribute.

Specified by:
evaluateAttribute in class AttributeEvaluator
Parameters:
attribute - the index of the attribute to be evaluated
Returns:
the "merit" of the attribute
Throws:
java.lang.Exception - if the attribute could not be evaluated

toString

public java.lang.String toString()
Return a description of the evaluator

Returns:
description as a string

main

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

Parameters:
args - the options