weka.classifiers.meta

## Class IterativeClassifierOptimizer

- java.lang.Object
- - weka.classifiers.AbstractClassifier
  - - weka.classifiers.RandomizableClassifier
    - - weka.classifiers.meta.IterativeClassifierOptimizer

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, Classifier, AdditionalMeasureProducer, BatchPredictor, CapabilitiesHandler, CapabilitiesIgnorer, OptionHandler, Randomizable, RevisionHandler

      public class IterativeClassifierOptimizer
      extends RandomizableClassifier
      implements AdditionalMeasureProducer

  Chooses the best number of iterations for an IterativeClassifier such as LogitBoost using cross-validation. Optimizes the number of iterations of the given iterative classifier using cross-validation.

  Valid options are:

       -A
        If set, average estimate is used rather than one estimate from pooled predictions.

       -L <num>
        The number of iterations to look ahead for to find a better optimum.
        (default 50)

       -P <int>
        The size of the thread pool, for example, the number of cores in the CPU.
        (default 1)

       -E <int>
        The number of threads to use, which should be >= size of thread pool.
        (default 1)

       -I <num>
        Step size for the evaluation, if evaluation is time consuming.
        (default 1)

       -F <num>
        Number of folds for cross-validation.
        (default 10)

       -R <num>
        Number of runs for cross-validation.
        (default 1)

       -W
        Full name of base classifier.
        (default: weka.classifiers.meta.LogitBoost)

       -metric <name>
        Evaluation metric to optimise (default rmse). Available metrics:
        correct,incorrect,kappa,total cost,average cost,kb relative,kb information,
        correlation,complexity 0,complexity scheme,complexity improvement,
        mae,rmse,rae,rrse,coverage,region size,tp rate,fp rate,precision,recall,
        f-measure,mcc,roc area,prc area

       -class-value-index <0-based index>
        Class value index to optimise. Ignored for all but information-retrieval
        type metrics (such as roc area). If unspecified (or a negative value is supplied),
        and an information-retrieval metric is specified, then the class-weighted average
        metric used. (default -1)

       -S <num>
        Random number seed.
        (default 1)

       -output-debug-info
        If set, classifier is run in debug mode and
        may output additional info to the console

       -do-not-check-capabilities
        If set, classifier capabilities are not checked before classifier is built
        (use with caution).

       Options specific to classifier weka.classifiers.meta.LogitBoost:

       -Q
        Use resampling instead of reweighting for boosting.

       -P <percent>
        Percentage of weight mass to base training on.
        (default 100, reduce to around 90 speed up)

       -L <num>
        Threshold on the improvement of the likelihood.
        (default -Double.MAX_VALUE)

       -H <num>
        Shrinkage parameter.
        (default 1)

       -Z <num>
        Z max threshold for responses.
        (default 3)

       -O <int>
        The size of the thread pool, for example, the number of cores in the CPU. (default 1)

       -E <int>
        The number of threads to use for batch prediction, which should be >= size of thread pool.
        (default 1)

       -S <num>
        Random number seed.
        (default 1)

       -I <num>
        Number of iterations.
        (default 10)

       -W
        Full name of base classifier.
        (default: weka.classifiers.trees.DecisionStump)

       -output-debug-info
        If set, classifier is run in debug mode and
        may output additional info to the console

       -do-not-check-capabilities
        If set, classifier capabilities are not checked before classifier is built
        (use with caution).

       Options specific to classifier weka.classifiers.trees.DecisionStump:

       -output-debug-info
        If set, classifier is run in debug mode and
        may output additional info to the console

       -do-not-check-capabilities
        If set, classifier capabilities are not checked before classifier is built
        (use with caution).

  Version:
    $Revision: 10141 $
  Author:
    Eibe Frank (eibe@cs.waikato.ac.nz)
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Tag[]` | `TAGS_EVAL`

    - ### Fields inherited from class weka.classifiers.AbstractClassifier

      `NUM_DECIMAL_PLACES_DEFAULT`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `IterativeClassifierOptimizer()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `buildClassifier(Instances data)` Builds the classifier.
    `java.lang.String` | `classValueIndexTipText()` Returns the tip text for this property
    `double[]` | `distributionForInstance(Instance inst)` Returns the class distribution for an instance.
    `java.util.Enumeration<java.lang.String>` | `enumerateMeasures()` Returns an enumeration of the additional measure names
    `java.lang.String` | `evaluationMetricTipText()` Returns the tip text for this property
    `Capabilities` | `getCapabilities()` Returns default capabilities of the base classifier.
    `int` | `getClassValueIndex()` Get the class value index to use
    `SelectedTag` | `getEvaluationMetric()` Get the evaluation metric to use
    `IterativeClassifier` | `getIterativeClassifier()` Get the classifier used as the base learner.
    `int` | `getLookAheadIterations()` Get the value of LookAheadIterations.
    `double` | `getMeasure(java.lang.String additionalMeasureName)` Returns the value of the named measure
    `int` | `getNumFolds()` Get the value of NumFolds.
    `int` | `getNumRuns()` Get the value of NumRuns.
    `int` | `getNumThreads()` Gets the number of threads.
    `java.lang.String[]` | `getOptions()` Gets the current settings of the Classifier.
    `int` | `getPoolSize()` Gets the number of threads.
    `java.lang.String` | `getRevision()` Returns the revision string.
    `int` | `getStepSize()` Get the value of StepSize.
    `boolean` | `getUseAverage()` Get the value of UseAverage.
    `java.lang.String` | `globalInfo()` Returns a string describing classifier
    `java.lang.String` | `iterativeClassifierTipText()` Returns the tip text for this property
    `java.util.Enumeration<Option>` | `listOptions()` Returns an enumeration describing the available options.
    `java.lang.String` | `lookAheadIterationsTipText()` Returns the tip text for this property
    `static void` | `main(java.lang.String[] argv)` Main method for testing this class.
    `double` | `measureBestNumIts()` Returns the best number of iterations
    `double` | `measureBestVal()` Returns the measure for the best model
    `java.lang.String` | `numFoldsTipText()` Returns the tip text for this property
    `java.lang.String` | `numRunsTipText()` Returns the tip text for this property
    `java.lang.String` | `numThreadsTipText()`
    `java.lang.String` | `poolSizeTipText()`
    `void` | `setClassValueIndex(int i)` Set the class value index to use
    `void` | `setEvaluationMetric(SelectedTag metric)` Set the evaluation metric to use
    `void` | `setIterativeClassifier(IterativeClassifier newIterativeClassifier)` Set the base learner.
    `void` | `setLookAheadIterations(int newLookAheadIterations)` Set the value of LookAheadIterations.
    `void` | `setNumFolds(int newNumFolds)` Set the value of NumFolds.
    `void` | `setNumRuns(int newNumRuns)` Set the value of NumRuns.
    `void` | `setNumThreads(int nT)` Sets the number of threads
    `void` | `setOptions(java.lang.String[] options)` Parses a given list of options.
    `void` | `setPoolSize(int nT)` Sets the number of threads
    `void` | `setStepSize(int newStepSize)` Set the value of StepSize.
    `void` | `setUseAverage(boolean newUseAverage)` Set the value of UseAverage.
    `java.lang.String` | `stepSizeTipText()` Returns the tip text for this property
    `java.lang.String` | `toString()` Returns a string describing the classifier.
    `java.lang.String` | `useAverageTipText()` Returns the tip text for this property

    - ### Methods inherited from class weka.classifiers.RandomizableClassifier

      `getSeed, seedTipText, setSeed`

    - ### Methods inherited from class weka.classifiers.AbstractClassifier

      `batchSizeTipText, classifyInstance, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### TAGS_EVAL

          public static Tag[] TAGS_EVAL

  - ### Constructor Detail

    - #### IterativeClassifierOptimizer

          public IterativeClassifierOptimizer()

  - ### Method Detail

    - #### globalInfo

          public java.lang.String globalInfo()

      Returns a string describing classifier
      Returns:
        a description suitable for displaying in the explorer/experimenter gui

    - #### useAverageTipText

          public java.lang.String useAverageTipText()

      Returns the tip text for this property
      Returns:
        tip text for this property suitable for displaying in the explorer/experimenter gui

    - #### getUseAverage

          public boolean getUseAverage()

      Get the value of UseAverage.
      Returns:
        Value of UseAverage.

    - #### setUseAverage

          public void setUseAverage(boolean newUseAverage)

      Set the value of UseAverage.
      Parameters:
        `newUseAverage` - Value to assign to UseAverage.

    - #### numThreadsTipText

          public java.lang.String numThreadsTipText()

      Returns:
        a string to describe the option

    - #### getNumThreads

          public int getNumThreads()

      Gets the number of threads.

    - #### setNumThreads

          public void setNumThreads(int nT)

      Sets the number of threads

    - #### poolSizeTipText

          public java.lang.String poolSizeTipText()

      Returns:
        a string to describe the option

    - #### getPoolSize

          public int getPoolSize()

      Gets the number of threads.

    - #### setPoolSize

          public void setPoolSize(int nT)

      Sets the number of threads

    - #### stepSizeTipText

          public java.lang.String stepSizeTipText()

      Returns the tip text for this property
      Returns:
        tip text for this property suitable for displaying in the explorer/experimenter gui

    - #### getStepSize

          public int getStepSize()

      Get the value of StepSize.
      Returns:
        Value of StepSize.

    - #### setStepSize

          public void setStepSize(int newStepSize)

      Set the value of StepSize.
      Parameters:
        `newStepSize` - Value to assign to StepSize.

    - #### numRunsTipText

          public java.lang.String numRunsTipText()

      Returns the tip text for this property
      Returns:
        tip text for this property suitable for displaying in the explorer/experimenter gui

    - #### getNumRuns

          public int getNumRuns()

      Get the value of NumRuns.
      Returns:
        Value of NumRuns.

    - #### setNumRuns

          public void setNumRuns(int newNumRuns)

      Set the value of NumRuns.
      Parameters:
        `newNumRuns` - Value to assign to NumRuns.

    - #### 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()

      Get the value of NumFolds.
      Returns:
        Value of NumFolds.

    - #### setNumFolds

          public void setNumFolds(int newNumFolds)

      Set the value of NumFolds.
      Parameters:
        `newNumFolds` - Value to assign to NumFolds.

    - #### lookAheadIterationsTipText

          public java.lang.String lookAheadIterationsTipText()

      Returns the tip text for this property
      Returns:
        tip text for this property suitable for displaying in the explorer/experimenter gui

    - #### getLookAheadIterations

          public int getLookAheadIterations()

      Get the value of LookAheadIterations.
      Returns:
        Value of LookAheadIterations.

    - #### setLookAheadIterations

          public void setLookAheadIterations(int newLookAheadIterations)

      Set the value of LookAheadIterations.
      Parameters:
        `newLookAheadIterations` - Value to assign to LookAheadIterations.

    - #### buildClassifier

          public void buildClassifier(Instances data)
                               throws java.lang.Exception

      Builds the classifier.
      Specified by:
        `buildClassifier` in interface `Classifier`
      Parameters:
        `data` - set of instances serving as training data
      Throws:
        `java.lang.Exception` - if the classifier has not been generated successfully

    - #### distributionForInstance

          public double[] distributionForInstance(Instance inst)
                                           throws java.lang.Exception

      Returns the class distribution for an instance.
      Specified by:
        `distributionForInstance` in interface `Classifier`
      Overrides:
        `distributionForInstance` in class `AbstractClassifier`
      Parameters:
        `inst` - the instance to be classified
      Returns:
        an array containing the estimated membership probabilities of the test instance in each class or the numeric prediction
      Throws:
        `java.lang.Exception` - if distribution could not be computed successfully

    - #### toString

          public java.lang.String toString()

      Returns a string describing the classifier.
      Overrides:
        `toString` in class `java.lang.Object`

    - #### listOptions

          public java.util.Enumeration<Option> listOptions()

      Returns an enumeration describing the available options.
      Specified by:
        `listOptions` in interface `OptionHandler`
      Overrides:
        `listOptions` in class `RandomizableClassifier`
      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:

      -W classname
      Specify the full class name of the base learner.

      Options after -- are passed to the designated classifier.

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

    - #### evaluationMetricTipText

          public java.lang.String evaluationMetricTipText()

      Returns the tip text for this property
      Returns:
        tip text for this property suitable for displaying in the explorer/experimenter gui

    - #### setEvaluationMetric

          public void setEvaluationMetric(SelectedTag metric)

      Set the evaluation metric to use
      Parameters:
        `metric` - the metric to use

    - #### getEvaluationMetric

          public SelectedTag getEvaluationMetric()

      Get the evaluation metric to use
      Returns:
        the evaluation metric to use

    - #### classValueIndexTipText

          public java.lang.String classValueIndexTipText()

      Returns the tip text for this property
      Returns:
        tip text for this property suitable for displaying in the explorer/experimenter gui

    - #### setClassValueIndex

          public void setClassValueIndex(int i)

      Set the class value index to use
      Parameters:
        `i` - the class value index to use

    - #### getClassValueIndex

          public int getClassValueIndex()

      Get the class value index to use
      Returns:
        the class value index to use

    - #### iterativeClassifierTipText

          public java.lang.String iterativeClassifierTipText()

      Returns the tip text for this property
      Returns:
        tip text for this property suitable for displaying in the explorer/experimenter gui

    - #### getCapabilities

          public Capabilities getCapabilities()

      Returns default capabilities of the base classifier.
      Specified by:
        `getCapabilities` in interface `Classifier`
      Specified by:
        `getCapabilities` in interface `CapabilitiesHandler`
      Overrides:
        `getCapabilities` in class `AbstractClassifier`
      Returns:
        the capabilities of the base classifier
      See Also:
        `Capabilities`

    - #### setIterativeClassifier

          public void setIterativeClassifier(IterativeClassifier newIterativeClassifier)

      Set the base learner.
      Parameters:
        `newIterativeClassifier` - the classifier to use.

    - #### getIterativeClassifier

          public IterativeClassifier getIterativeClassifier()

      Get the classifier used as the base learner.
      Returns:
        the classifier used as the classifier

    - #### getRevision

          public java.lang.String getRevision()

      Returns the revision string.
      Specified by:
        `getRevision` in interface `RevisionHandler`
      Overrides:
        `getRevision` in class `AbstractClassifier`
      Returns:
        the revision

    - #### measureBestNumIts

          public double measureBestNumIts()

      Returns the best number of iterations
      Returns:
        the best number of iterations

    - #### measureBestVal

          public double measureBestVal()

      Returns the measure for the best model
      Returns:
        the number of leaves

    - #### enumerateMeasures

          public java.util.Enumeration<java.lang.String> enumerateMeasures()

      Returns an enumeration of the additional measure names
      Specified by:
        `enumerateMeasures` in interface `AdditionalMeasureProducer`
      Returns:
        an enumeration of the measure names

    - #### getMeasure

          public double getMeasure(java.lang.String additionalMeasureName)

      Returns the value of the named measure
      Specified by:
        `getMeasure` in interface `AdditionalMeasureProducer`
      Parameters:
        `additionalMeasureName` - the name of the measure to query for its value
      Returns:
        the value of the named measure
      Throws:
        `java.lang.IllegalArgumentException` - if the named measure is not supported

    - #### main

          public static void main(java.lang.String[] argv)

      Main method for testing this class.
      Parameters:
        `argv` - the options