Class IterativeClassifierOptimizer

All Implemented Interfaces:
Serializable, Cloneable, Classifier, AdditionalMeasureProducer, BatchPredictor, CapabilitiesHandler, CapabilitiesIgnorer, CommandlineRunnable, 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 or a percentage split evaluation. Optimizes the number of iterations of the given iterative classifier using cross-validation or a percentage split evaluation.

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)
 -percentage <num>
  The percentage of data to be used for training (if 0, k-fold cross-validation is used).
  (default 0)
 -order
  Whether to preserve order when a percentage split evaluation is performed.
  
 -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:
  • Field Details

    • TAGS_EVAL

      public static Tag[] TAGS_EVAL
  • Constructor Details

    • IterativeClassifierOptimizer

      public IterativeClassifierOptimizer()
  • Method Details

    • globalInfo

      public String globalInfo()
      Returns a string describing classifier
      Returns:
      a description suitable for displaying in the explorer/experimenter gui
    • useAverageTipText

      public 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 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 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 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 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 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 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.
    • splitPercentageTipText

      public String splitPercentageTipText()
      Returns the tip text for this property
      Returns:
      tip text for this property suitable for displaying in the explorer/experimenter gui
    • getSplitPercentage

      public double getSplitPercentage()
      Get the value of SplitPercentage.
      Returns:
      Value of SplitPercentage.
    • setSplitPercentage

      public void setSplitPercentage(double newSplitPercentage)
      Set the value of SplitPercentage.
      Parameters:
      newSplitPercentage - Value to assign to SplitPercentage.
    • preserveOrderInPercentageSplitEvaluationTipText

      public String preserveOrderInPercentageSplitEvaluationTipText()
      Returns the tip text for this property
      Returns:
      tip text for this property suitable for displaying in the explorer/experimenter gui
    • getPreserveOrderInPercentageSplitEvaluation

      public boolean getPreserveOrderInPercentageSplitEvaluation()
      Get the value of PreserveOrderInPercentageSplitEvaluation.
      Returns:
      Value of PreserveOrderInPercentageSplitEvaluation.
    • setPreserveOrderInPercentageSplitEvaluation

      public void setPreserveOrderInPercentageSplitEvaluation(boolean newPreserveOrderInPercentageSplitEvaluation)
      Set the value of PreserveOrderInPercentageSplitEvaluation.
      Parameters:
      newPreserveOrderInPercentageSplitEvaluation - Value to assign to PreserveOrderInPercentageSplitEvaluation.
    • buildClassifier

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

      public double[] distributionForInstance(Instance inst) throws 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:
      Exception - if distribution could not be computed successfully
    • toString

      public String toString()
      Returns a string describing the classifier.
      Overrides:
      toString in class Object
    • listOptions

      public 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(String[] options) throws Exception
      Parses a given list of options. 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:
      Exception - if an option is not supported
    • getOptions

      public 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 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 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 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 CapabilitiesHandler
      Specified by:
      getCapabilities in interface Classifier
      Overrides:
      getCapabilities in class AbstractClassifier
      Returns:
      the capabilities of the base classifier
      See Also:
    • 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 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 Enumeration<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(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:
      IllegalArgumentException - if the named measure is not supported
    • main

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