Class CVParameterSelection

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, CapabilitiesHandler, Drawable, OptionHandler, Randomizable, RevisionHandler, Summarizable, TechnicalInformationHandler

    public class CVParameterSelection
    extends RandomizableSingleClassifierEnhancer
    implements Drawable, Summarizable, TechnicalInformationHandler
    Class for performing parameter selection by cross-validation for any classifier.

    For more information, see:

    R. Kohavi (1995). Wrappers for Performance Enhancement and Oblivious Decision Graphs. Department of Computer Science, Stanford University.

    BibTeX:

     @phdthesis{Kohavi1995,
        address = {Department of Computer Science, Stanford University},
        author = {R. Kohavi},
        school = {Stanford University},
        title = {Wrappers for Performance Enhancement and Oblivious Decision Graphs},
        year = {1995}
     }
     

    Valid options are:

     -X <number of folds>
      Number of folds used for cross validation (default 10).
     -P <classifier parameter>
      Classifier parameter options.
      eg: "N 1 5 10" Sets an optimisation parameter for the
      classifier with name -N, with lower bound 1, upper bound
      5, and 10 optimisation steps. The upper bound may be the
      character 'A' or 'I' to substitute the number of
      attributes or instances in the training data,
      respectively. This parameter may be supplied more than
      once to optimise over several classifier options
      simultaneously.
     -S <num>
      Random number seed.
      (default 1)
     -D
      If set, classifier is run in debug mode and
      may output additional info to the console
     -W
      Full name of base classifier.
      (default: weka.classifiers.rules.ZeroR)
     
     Options specific to classifier weka.classifiers.rules.ZeroR:
     
     -D
      If set, classifier is run in debug mode and
      may output additional info to the console
    Options after -- are passed to the designated sub-classifier.

    Version:
    $Revision: 8180 $
    Author:
    Len Trigg (trigg@cs.waikato.ac.nz)
    See Also:
    Serialized Form
    • Constructor Detail

      • CVParameterSelection

        public CVParameterSelection()
    • Method Detail

      • globalInfo

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

        public TechnicalInformation getTechnicalInformation()
        Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.
        Specified by:
        getTechnicalInformation in interface TechnicalInformationHandler
        Returns:
        the technical information about this class
      • setOptions

        public void setOptions​(java.lang.String[] options)
                        throws java.lang.Exception
        Parses a given list of options.

        Valid options are:

         -X <number of folds>
          Number of folds used for cross validation (default 10).
         -P <classifier parameter>
          Classifier parameter options.
          eg: "N 1 5 10" Sets an optimisation parameter for the
          classifier with name -N, with lower bound 1, upper bound
          5, and 10 optimisation steps. The upper bound may be the
          character 'A' or 'I' to substitute the number of
          attributes or instances in the training data,
          respectively. This parameter may be supplied more than
          once to optimise over several classifier options
          simultaneously.
         -S <num>
          Random number seed.
          (default 1)
         -D
          If set, classifier is run in debug mode and
          may output additional info to the console
         -W
          Full name of base classifier.
          (default: weka.classifiers.rules.ZeroR)
         
         Options specific to classifier weka.classifiers.rules.ZeroR:
         
         -D
          If set, classifier is run in debug mode and
          may output additional info to the console
        Options after -- are passed to the designated sub-classifier.

        Specified by:
        setOptions in interface OptionHandler
        Overrides:
        setOptions in class RandomizableSingleClassifierEnhancer
        Parameters:
        options - the list of options as an array of strings
        Throws:
        java.lang.Exception - if an option is not supported
      • getBestClassifierOptions

        public java.lang.String[] getBestClassifierOptions()
        Returns (a copy of) the best options found for the classifier.
        Returns:
        the best options
      • buildClassifier

        public void buildClassifier​(Instances instances)
                             throws java.lang.Exception
        Generates the classifier.
        Specified by:
        buildClassifier in class Classifier
        Parameters:
        instances - set of instances serving as training data
        Throws:
        java.lang.Exception - if the classifier has not been generated successfully
      • distributionForInstance

        public double[] distributionForInstance​(Instance instance)
                                         throws java.lang.Exception
        Predicts the class distribution for the given test instance.
        Overrides:
        distributionForInstance in class Classifier
        Parameters:
        instance - the instance to be classified
        Returns:
        the predicted class value
        Throws:
        java.lang.Exception - if an error occurred during the prediction
      • addCVParameter

        public void addCVParameter​(java.lang.String cvParam)
                            throws java.lang.Exception
        Adds a scheme parameter to the list of parameters to be set by cross-validation
        Parameters:
        cvParam - the string representation of a scheme parameter. The format is:
        param_char lower_bound upper_bound number_of_steps
        eg to search a parameter -P from 1 to 10 by increments of 1:
        P 1 10 11
        Throws:
        java.lang.Exception - if the parameter specifier is of the wrong format
      • getCVParameter

        public java.lang.String getCVParameter​(int index)
        Gets the scheme paramter with the given index.
        Parameters:
        index - the index for the parameter
        Returns:
        the scheme parameter
      • CVParametersTipText

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

        public java.lang.Object[] getCVParameters()
        Get method for CVParameters.
        Returns:
        the CVParameters
      • setCVParameters

        public void setCVParameters​(java.lang.Object[] params)
                             throws java.lang.Exception
        Set method for CVParameters.
        Parameters:
        params - the CVParameters to use
        Throws:
        java.lang.Exception - if the setting of the CVParameters fails
      • numFoldsTipText

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

        public int getNumFolds()
        Gets the number of folds for the cross-validation.
        Returns:
        the number of folds for the cross-validation
      • setNumFolds

        public void setNumFolds​(int numFolds)
                         throws java.lang.Exception
        Sets the number of folds for the cross-validation.
        Parameters:
        numFolds - the number of folds for the cross-validation
        Throws:
        java.lang.Exception - if parameter illegal
      • graphType

        public int graphType()
        Returns the type of graph this classifier represents.
        Specified by:
        graphType in interface Drawable
        Returns:
        the type of graph this classifier represents
      • graph

        public java.lang.String graph()
                               throws java.lang.Exception
        Returns graph describing the classifier (if possible).
        Specified by:
        graph in interface Drawable
        Returns:
        the graph of the classifier in dotty format
        Throws:
        java.lang.Exception - if the classifier cannot be graphed
      • toString

        public java.lang.String toString()
        Returns description of the cross-validated classifier.
        Overrides:
        toString in class java.lang.Object
        Returns:
        description of the cross-validated classifier as a string
      • toSummaryString

        public java.lang.String toSummaryString()
        A concise description of the model.
        Specified by:
        toSummaryString in interface Summarizable
        Returns:
        a concise description of the model
      • main

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