Class SimpleLinearRegressionWithAccess

  • All Implemented Interfaces:
    Serializable, Cloneable, weka.classifiers.Classifier, weka.core.BatchPredictor, weka.core.CapabilitiesHandler, weka.core.CapabilitiesIgnorer, weka.core.CommandlineRunnable, weka.core.OptionHandler, weka.core.RevisionHandler, weka.core.WeightedInstancesHandler
    Direct Known Subclasses:
    SimpleLinearRegressionIntervalEstimator

    public class SimpleLinearRegressionWithAccess
    extends weka.classifiers.AbstractClassifier
    implements weka.core.WeightedInstancesHandler
    Learns a simple linear regression model. Picks the attribute that results in the lowest squared error. Can only deal with numeric attributes.
    Makes standard errors available.

    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 ([email protected])
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected weka.core.Attribute m_attribute
      The chosen attribute
      protected int m_attributeIndex
      The index of the chosen attribute
      protected double m_classMeanForMissing
      The class mean for missing values
      protected int m_df
      Degrees of freedom, used in statistical calculations
      protected double m_fstat
      F-statistic for the regression
      protected double m_intercept
      The intercept
      protected boolean m_outputAdditionalStats
      Whether to output additional statistics such as std.
      protected double m_rsquared
      R^2 value for the regression
      protected double m_rsquaredAdj
      Adjusted R^2 value for the regression
      protected double m_seIntercept
      standard error of the intercept
      protected double m_seSlope
      standard error of the slope
      protected double m_slope
      The slope
      protected boolean m_suppressErrorMessage
      If true, suppress error message if no useful attribute was found
      protected double m_tstatIntercept
      t-statistic of the intercept
      protected double m_tstatSlope
      t-statistic of the slope
      • Fields inherited from class weka.classifiers.AbstractClassifier

        BATCH_SIZE_DEFAULT, m_BatchSize, m_Debug, m_DoNotCheckCapabilities, m_numDecimalPlaces, NUM_DECIMAL_PLACES_DEFAULT
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void buildClassifier​(weka.core.Instances insts)
      Builds a simple linear regression model given the supplied training data.
      double classifyInstance​(weka.core.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.
      weka.core.Capabilities getCapabilities()
      Returns default capabilities of the classifier.
      double getIntercept()
      Returns the intercept of the function.
      double getInterceptSE()
      Returns the standard error intercept of the function.
      String[] getOptions()
      Gets the current settings of the classifier.
      boolean getOutputAdditionalStats()
      Get whether to output additional statistics (such as std.
      String getRevision()
      Returns the revision string.
      double getSlope()
      Returns the slope of the function.
      double getSlopeSE()
      Returns the standard error of slope of the function.
      String globalInfo()
      Returns a string describing this classifier
      Enumeration<weka.core.Option> listOptions()
      Returns an enumeration describing the available options.
      static void main​(String[] argv)
      Main method for testing this class
      String outputAdditionalStatsTipText()
      Returns the tip text for this property.
      void setOptions​(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.
      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, postExecution, preExecution, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
    • Field Detail

      • m_attribute

        protected weka.core.Attribute m_attribute
        The chosen attribute
      • m_attributeIndex

        protected int m_attributeIndex
        The index of the chosen attribute
      • m_slope

        protected double m_slope
        The slope
      • m_intercept

        protected double m_intercept
        The intercept
      • m_classMeanForMissing

        protected double m_classMeanForMissing
        The class mean for missing values
      • m_outputAdditionalStats

        protected boolean m_outputAdditionalStats
        Whether to output additional statistics such as std. dev. of coefficients and t-stats
      • m_df

        protected int m_df
        Degrees of freedom, used in statistical calculations
      • m_seSlope

        protected double m_seSlope
        standard error of the slope
      • m_seIntercept

        protected double m_seIntercept
        standard error of the intercept
      • m_tstatSlope

        protected double m_tstatSlope
        t-statistic of the slope
      • m_tstatIntercept

        protected double m_tstatIntercept
        t-statistic of the intercept
      • m_rsquared

        protected double m_rsquared
        R^2 value for the regression
      • m_rsquaredAdj

        protected double m_rsquaredAdj
        Adjusted R^2 value for the regression
      • m_fstat

        protected double m_fstat
        F-statistic for the regression
      • m_suppressErrorMessage

        protected boolean m_suppressErrorMessage
        If true, suppress error message if no useful attribute was found
    • Constructor Detail

      • SimpleLinearRegressionWithAccess

        public SimpleLinearRegressionWithAccess()
    • Method Detail

      • globalInfo

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

        public Enumeration<weka.core.Option> listOptions()
        Returns an enumeration describing the available options.
        Specified by:
        listOptions in interface weka.core.OptionHandler
        Overrides:
        listOptions in class weka.classifiers.AbstractClassifier
        Returns:
        an enumeration of all the available options.
      • setOptions

        public void setOptions​(String[] options)
                        throws 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 weka.core.OptionHandler
        Overrides:
        setOptions in class weka.classifiers.AbstractClassifier
        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 weka.core.OptionHandler
        Overrides:
        getOptions in class weka.classifiers.AbstractClassifier
        Returns:
        an array of strings suitable for passing to setOptions
      • outputAdditionalStatsTipText

        public 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​(weka.core.Instance inst)
                                throws Exception
        Generate a prediction for the supplied instance.
        Specified by:
        classifyInstance in interface weka.classifiers.Classifier
        Overrides:
        classifyInstance in class weka.classifiers.AbstractClassifier
        Parameters:
        inst - the instance to predict.
        Returns:
        the prediction
        Throws:
        Exception - if an error occurs
      • getCapabilities

        public weka.core.Capabilities getCapabilities()
        Returns default capabilities of the classifier.
        Specified by:
        getCapabilities in interface weka.core.CapabilitiesHandler
        Specified by:
        getCapabilities in interface weka.classifiers.Classifier
        Overrides:
        getCapabilities in class weka.classifiers.AbstractClassifier
        Returns:
        the capabilities of this classifier
      • buildClassifier

        public void buildClassifier​(weka.core.Instances insts)
                             throws Exception
        Builds a simple linear regression model given the supplied training data.
        Specified by:
        buildClassifier in interface weka.classifiers.Classifier
        Parameters:
        insts - the training data.
        Throws:
        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.
      • getSlopeSE

        public double getSlopeSE()
        Returns the standard error of slope of the function.
        Returns:
        the SE of the slope.
      • getIntercept

        public double getIntercept()
        Returns the intercept of the function.
        Returns:
        the intercept.
      • getInterceptSE

        public double getInterceptSE()
        Returns the standard error intercept of the function.
        Returns:
        the standard error of 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 String toString()
        Returns a description of this classifier as a string
        Overrides:
        toString in class Object
        Returns:
        a description of the classifier.
      • getRevision

        public String getRevision()
        Returns the revision string.
        Specified by:
        getRevision in interface weka.core.RevisionHandler
        Overrides:
        getRevision in class weka.classifiers.AbstractClassifier
        Returns:
        the revision
      • main

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