weka.classifiers.meta

## Class AdditiveRegression

- java.lang.Object
- - weka.classifiers.AbstractClassifier
  - - weka.classifiers.SingleClassifierEnhancer
    - - weka.classifiers.IteratedSingleClassifierEnhancer
      - - weka.classifiers.meta.AdditiveRegression

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, Classifier, IterativeClassifier, AdditionalMeasureProducer, BatchPredictor, CapabilitiesHandler, CapabilitiesIgnorer, CommandlineRunnable, OptionHandler, RevisionHandler, TechnicalInformationHandler, WeightedInstancesHandler

      public class AdditiveRegression
      extends IteratedSingleClassifierEnhancer
      implements OptionHandler, AdditionalMeasureProducer, WeightedInstancesHandler, TechnicalInformationHandler, IterativeClassifier

  Meta classifier that enhances the performance of a regression base classifier. Each iteration fits a model to the residuals left by the classifier on the previous iteration. Prediction is accomplished by adding the predictions of each classifier. Reducing the shrinkage (learning rate) parameter helps prevent overfitting and has a smoothing effect but increases the learning time.
  For more information see:
  J.H. Friedman (1999). Stochastic Gradient Boosting.

  BibTeX:

       @techreport{Friedman1999,
          author = {J.H. Friedman},
          institution = {Stanford University},
          title = {Stochastic Gradient Boosting},
          year = {1999},
          PS = {http://www-stat.stanford.edu/\~jhf/ftp/stobst.ps}
       }

  Valid options are:

       -S
        Specify shrinkage rate. (default = 1.0, ie. no shrinkage)

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

       -A
        Minimize absolute error instead of squared error (assumes that base learner minimizes absolute error).

        -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.trees.DecisionStump)

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

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

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

- - ### Field Summary

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

      `BATCH_SIZE_DEFAULT, NUM_DECIMAL_PLACES_DEFAULT`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AdditiveRegression()` Default constructor specifying DecisionStump as the classifier
    `AdditiveRegression(Classifier classifier)` Constructor which takes base classifier as argument.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `buildClassifier(Instances data)` Method used to build the classifier.
    `double` | `classifyInstance(Instance inst)` Classify an instance.
    `void` | `done()` Clean up.
    `java.util.Enumeration<java.lang.String>` | `enumerateMeasures()` Returns an enumeration of the additional measure names
    `Capabilities` | `getCapabilities()` Returns default capabilities of the classifier.
    `double` | `getMeasure(java.lang.String additionalMeasureName)` Returns the value of the named measure
    `boolean` | `getMinimizeAbsoluteError()` Gets whether absolute error is to be minimized.
    `java.lang.String[]` | `getOptions()` Gets the current settings of the Classifier.
    `java.lang.String` | `getRevision()` Returns the revision string.
    `double` | `getShrinkage()` Get the shrinkage rate.
    `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.
    `java.lang.String` | `globalInfo()` Returns a string describing this attribute evaluator
    `void` | `initializeClassifier(Instances data)` Initialize classifier.
    `java.util.Enumeration<Option>` | `listOptions()` Returns an enumeration describing the available options.
    `static void` | `main(java.lang.String[] argv)` Main method for testing this class.
    `double` | `measureNumIterations()` return the number of iterations (base classifiers) completed
    `java.lang.String` | `minimizeAbsoluteErrorTipText()` Returns the tip text for this property
    `boolean` | `next()` Perform another iteration.
    `void` | `setMinimizeAbsoluteError(boolean f)` Sets whether absolute error is to be minimized.
    `void` | `setOptions(java.lang.String[] options)` Parses a given list of options.
    `void` | `setShrinkage(double l)` Set the shrinkage parameter
    `java.lang.String` | `shrinkageTipText()` Returns the tip text for this property
    `java.lang.String` | `toString()` Returns textual description of the classifier.

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

      `getNumIterations, numIterationsTipText, setNumIterations`

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

      `classifierTipText, getClassifier, postExecution, preExecution, setClassifier`

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

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

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

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

    - ### Methods inherited from interface weka.classifiers.Classifier

      `distributionForInstance`

- - ### Constructor Detail

    - #### AdditiveRegression

          public AdditiveRegression()

      Default constructor specifying DecisionStump as the classifier

    - #### AdditiveRegression

          public AdditiveRegression(Classifier classifier)

      Constructor which takes base classifier as argument.
      Parameters:
        `classifier` - the base classifier to use

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

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

    - #### listOptions

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

      Returns an enumeration describing the available options.
      Specified by:
        `listOptions` in interface `OptionHandler`
      Overrides:
        `listOptions` in class `IteratedSingleClassifierEnhancer`
      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
            Specify shrinkage rate. (default = 1.0, ie. no shrinkage)

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

           -A
            Minimize absolute error instead of squared error (assumes that base learner minimizes absolute error).

            -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.trees.DecisionStump)

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

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

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

    - #### shrinkageTipText

          public java.lang.String shrinkageTipText()

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

    - #### setShrinkage

          public void setShrinkage(double l)

      Set the shrinkage parameter
      Parameters:
        `l` - the shrinkage rate.

    - #### getShrinkage

          public double getShrinkage()

      Get the shrinkage rate.
      Returns:
        the value of the learning rate

    - #### minimizeAbsoluteErrorTipText

          public java.lang.String minimizeAbsoluteErrorTipText()

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

    - #### setMinimizeAbsoluteError

          public void setMinimizeAbsoluteError(boolean f)

      Sets whether absolute error is to be minimized.
      Parameters:
        `f` - true if absolute error is to be minimized.

    - #### getMinimizeAbsoluteError

          public boolean getMinimizeAbsoluteError()

      Gets whether absolute error is to be minimized.
      Returns:
        true if absolute error is to be minimized

    - #### getCapabilities

          public Capabilities getCapabilities()

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

    - #### buildClassifier

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

      Method used to build the classifier.
      Specified by:
        `buildClassifier` in interface `Classifier`
      Overrides:
        `buildClassifier` in class `IteratedSingleClassifierEnhancer`
      Parameters:
        `data` - the training data to be used for generating the bagged classifier.
      Throws:
        `java.lang.Exception` - if the classifier could not be built successfully

    - #### initializeClassifier

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

      Initialize classifier.
      Specified by:
        `initializeClassifier` in interface `IterativeClassifier`
      Parameters:
        `data` - the training data
      Throws:
        `java.lang.Exception` - if the classifier could not be initialized successfully

    - #### next

          public boolean next()
                       throws java.lang.Exception

      Perform another iteration.
      Specified by:
        `next` in interface `IterativeClassifier`
      Returns:
        false if no further iterations could be performed, true otherwise
      Throws:
        `java.lang.Exception` - if this iteration fails for unexpected reasons

    - #### done

          public void done()

      Clean up.
      Specified by:
        `done` in interface `IterativeClassifier`

    - #### classifyInstance

          public double classifyInstance(Instance inst)
                                  throws java.lang.Exception

      Classify an instance.
      Specified by:
        `classifyInstance` in interface `Classifier`
      Overrides:
        `classifyInstance` in class `AbstractClassifier`
      Parameters:
        `inst` - the instance to predict
      Returns:
        a prediction for the instance
      Throws:
        `java.lang.Exception` - if an error occurs

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

    - #### measureNumIterations

          public double measureNumIterations()

      return the number of iterations (base classifiers) completed
      Returns:
        the number of iterations (same as number of base classifier models)

    - #### toString

          public java.lang.String toString()

      Returns textual description of the classifier.
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        a description of the classifier as a string

    - #### getRevision

          public java.lang.String getRevision()

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

    - #### main

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

      Main method for testing this class.
      Parameters:
        `argv` - should contain the following arguments: -t training file [-T test file] [-c class index]