weka.classifiers.functions

## Class SimpleLinearRegression

- java.lang.Object
- - weka.classifiers.AbstractClassifier
  - - weka.classifiers.functions.SimpleLinearRegression

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

      public class SimpleLinearRegression
      extends AbstractClassifier
      implements WeightedInstancesHandler

  Learns a simple linear regression model. Picks the attribute that results in the lowest squared error. Can only deal with numeric attributes.

  Valid options are:

       -additional-stats
        Output additional statistics.

       -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: 11130 $
  Author:
    Eibe Frank (eibe@cs.waikato.ac.nz)
  See Also:
    Serialized Form

- - ### Field Summary

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

      `NUM_DECIMAL_PLACES_DEFAULT`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimpleLinearRegression()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `buildClassifier(Instances insts)` Builds a simple linear regression model given the supplied training data.
    `double` | `classifyInstance(Instance inst)` Generate a prediction for the supplied instance.
    `boolean` | `foundUsefulAttribute()` Returns true if a usable attribute was found.
    `int` | `getAttributeIndex()` Returns the index of the attribute used in the regression.
    `Capabilities` | `getCapabilities()` Returns default capabilities of the classifier.
    `double` | `getIntercept()` Returns the intercept of the function.
    `java.lang.String[]` | `getOptions()` Gets the current settings of the classifier.
    `boolean` | `getOutputAdditionalStats()` Get whether to output additional statistics (such as std.
    `java.lang.String` | `getRevision()` Returns the revision string.
    `double` | `getSlope()` Returns the slope of the function.
    `java.lang.String` | `globalInfo()` Returns a string describing this 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
    `java.lang.String` | `outputAdditionalStatsTipText()` Returns the tip text for this property.
    `void` | `setOptions(java.lang.String[] options)` Parses a given list of options.
    `void` | `setOutputAdditionalStats(boolean additional)` Set whether to output additional statistics (such as std.
    `void` | `setSuppressErrorMessage(boolean s)` Turn off the error message that is reported when no useful attribute is found.
    `java.lang.String` | `toString()` Returns a description of this classifier as a string

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

      `batchSizeTipText, debugTipText, distributionForInstance, 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`

- - ### Constructor Detail

    - #### SimpleLinearRegression

          public SimpleLinearRegression()

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

    - #### listOptions

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

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

           -additional-stats
            Output additional statistics.

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

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

    - #### outputAdditionalStatsTipText

          public java.lang.String outputAdditionalStatsTipText()

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

    - #### setOutputAdditionalStats

          public void setOutputAdditionalStats(boolean additional)

      Set whether to output additional statistics (such as std. deviation of coefficients and t-statistics
      Parameters:
        `additional` - true if additional stats are to be output

    - #### getOutputAdditionalStats

          public boolean getOutputAdditionalStats()

      Get whether to output additional statistics (such as std. deviation of coefficients and t-statistics
      Returns:
        true if additional stats are to be output

    - #### classifyInstance

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

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

    - #### 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 `AbstractClassifier`
      Returns:
        the capabilities of this classifier
      See Also:
        `Capabilities`

    - #### buildClassifier

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

      Builds a simple linear regression model given the supplied training data.
      Specified by:
        `buildClassifier` in interface `Classifier`
      Parameters:
        `insts` - the training data.
      Throws:
        `java.lang.Exception` - if an error occurs

    - #### foundUsefulAttribute

          public boolean foundUsefulAttribute()

      Returns true if a usable attribute was found.
      Returns:
        true if a usable attribute was found.

    - #### getAttributeIndex

          public int getAttributeIndex()

      Returns the index of the attribute used in the regression.
      Returns:
        the index of the attribute.

    - #### getSlope

          public double getSlope()

      Returns the slope of the function.
      Returns:
        the slope.

    - #### getIntercept

          public double getIntercept()

      Returns the intercept of the function.
      Returns:
        the intercept.

    - #### setSuppressErrorMessage

          public void setSuppressErrorMessage(boolean s)

      Turn off the error message that is reported when no useful attribute is found.
      Parameters:
        `s` - if set to true turns off the error message

    - #### toString

          public java.lang.String toString()

      Returns a description of this classifier as a string
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        a description of 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

    - #### main

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

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