Class OneRAttributeEval

  • All Implemented Interfaces:
    java.io.Serializable, AttributeEvaluator, CapabilitiesHandler, OptionHandler, RevisionHandler

    public class OneRAttributeEval
    extends ASEvaluation
    implements AttributeEvaluator, OptionHandler
    OneRAttributeEval :

    Evaluates the worth of an attribute by using the OneR classifier.

    Valid options are:

     -S <seed>
      Random number seed for cross validation
      (default = 1)
     -F <folds>
      Number of folds for cross validation
      (default = 10)
     -D
      Use training data for evaluation rather than cross validaton
     -B <minimum bucket size>
      Minimum number of objects in a bucket
      (passed on to OneR, default = 6)
    Version:
    $Revision: 11219 $
    Author:
    Mark Hall (mhall@cs.waikato.ac.nz)
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      OneRAttributeEval()
      Constructor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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
      Capabilities getCapabilities()
      Returns the capabilities of this evaluator.
      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()
      returns the current setup.
      java.lang.String getRevision()
      Returns the revision string.
      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
      int[] postProcess​(int[] attributeSet)
      Provides a chance for a attribute evaluator to do any special post processing of the selected attribute set.
      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 java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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 <seed>
          Random number seed for cross validation
          (default = 1)
         -F <folds>
          Number of folds for cross validation
          (default = 10)
         -D
          Use training data for evaluation rather than cross validaton
         -B <minimum bucket size>
          Minimum number of objects in a bucket
          (passed on to OneR, default = 6)
        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()
        returns the current setup.
        Specified by:
        getOptions in interface OptionHandler
        Returns:
        the options of the current setup
      • 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
      • 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 interface 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
        Overrides:
        toString in class java.lang.Object
        Returns:
        description as a string
      • postProcess

        public int[] postProcess​(int[] attributeSet)
        Description copied from class: ASEvaluation
        Provides a chance for a attribute evaluator to do any special post processing of the selected attribute set.
        Overrides:
        postProcess in class ASEvaluation
        Parameters:
        attributeSet - the set of attributes found by the search
        Returns:
        a possibly ranked list of postprocessed attributes
      • main

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