All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home

Class weka.classifiers.functions.LinearRegression

java.lang.Object
    |
    +----weka.classifiers.Classifier
            |
            +----weka.classifiers.functions.LinearRegression

public class LinearRegression
extends Classifier
implements OptionHandler, WeightedInstancesHandler
Class for using linear regression for prediction. Uses the Akaike criterion for model selection, and is able to deal with weighted instances.

Valid options are:

-D
Produce debugging output.

-S num
Set the attriute selection method to use. 1 = None, 2 = Greedy (default 0 = M5' method)

-C
Do not try to eliminate colinear attributes

-R num
The ridge parameter (default 1.0e-8)

Version:
$Revision: 1.18 $
Author:
Eibe Frank (eibe@cs.waikato.ac.nz)
Author:
Len Trigg (trigg@cs.waikato.ac.nz)

Variable Index

 o SELECTION_GREEDY
 
 o SELECTION_M5
 
 o SELECTION_NONE
 
 o TAGS_SELECTION
 

Constructor Index

 o LinearRegression()
 

Method Index

 o buildClassifier(Instances)
Builds a regression model for the given data.
 o classifyInstance(Instance)
Classifies the given instance using the linear regression function.
 o coefficients()
Returns the coefficients for this linear model.
 o getAttributeSelectionMethod()
Gets the method used to select attributes for use in the linear regression.
 o getDebug()
Controls whether debugging output will be printed
 o getEliminateColinearAttributes()
Get the value of EliminateColinearAttributes.
 o getOptions()
Gets the current settings of the classifier.
 o getRidge()
Get the value of Ridge.
 o listOptions()
Returns an enumeration describing the available options.
 o main(String[])
Generates a linear regression function predictor.
 o numParameters()
Get the number of coefficients used in the model
 o setAttributeSelectionMethod(SelectedTag)
Sets the method used to select attributes for use in the linear regression.
 o setDebug(boolean)
Controls whether debugging output will be printed
 o setEliminateColinearAttributes(boolean)
Set the value of EliminateColinearAttributes.
 o setOptions(String[])
Parses a given list of options.
 o setRidge(double)
Set the value of Ridge.
 o toString()
Outputs the linear regression model as a string.
 o turnChecksOff()
Turns off checks for missing values, etc.
 o turnChecksOn()
Turns on checks for missing values, etc.

Field Detail

 o SELECTION_M5
public static final int SELECTION_M5
 o SELECTION_NONE
public static final int SELECTION_NONE
 o SELECTION_GREEDY
public static final int SELECTION_GREEDY
 o TAGS_SELECTION
public static final Tag[] TAGS_SELECTION

Constructor Detail

 o LinearRegression
public LinearRegression()

Method Detail

 o turnChecksOff
public void turnChecksOff()
          Turns off checks for missing values, etc. Use with caution. Also turns off scaling.
 o turnChecksOn
public void turnChecksOn()
          Turns on checks for missing values, etc. Also turns on scaling.
 o buildClassifier
public void buildClassifier(Instances data) throws java.lang.Exception
          Builds a regression model for the given data.
Parameters:
data - the training data to be used for generating the linear regression function
Throws:
java.lang.Exception - if the classifier could not be built successfully
Overrides:
buildClassifier in class Classifier
 o classifyInstance
public double classifyInstance(Instance instance) throws java.lang.Exception
          Classifies the given instance using the linear regression function.
Parameters:
instance - the test instance
Returns:
the classification
Throws:
java.lang.Exception - if classification can't be done successfully
Overrides:
classifyInstance in class Classifier
 o toString
public java.lang.String toString()
          Outputs the linear regression model as a string.
Overrides:
toString in class java.lang.Object
 o listOptions
public java.util.Enumeration listOptions()
          Returns an enumeration describing the available options.
Returns:
an enumeration of all the available options.
 o setOptions
public void setOptions(java.lang.String options[]) throws java.lang.Exception
          Parses a given list of options. Valid options are:

-D
Produce debugging output.

-S num
Set the attriute selection method to use. 1 = None, 2 = Greedy (default 0 = M5' method)

-C
Do not try to eliminate colinear attributes

-R num
The ridge parameter (default 1.0e-8)

Parameters:
options - the list of options as an array of strings
Throws:
java.lang.Exception - if an option is not supported
 o coefficients
public double[] coefficients()
          Returns the coefficients for this linear model.
 o getOptions
public java.lang.String[] getOptions()
          Gets the current settings of the classifier.
Returns:
an array of strings suitable for passing to setOptions
 o getRidge
public double getRidge()
          Get the value of Ridge.
Returns:
Value of Ridge.
 o setRidge
public void setRidge(double newRidge)
          Set the value of Ridge.
Parameters:
newRidge - Value to assign to Ridge.
 o getEliminateColinearAttributes
public boolean getEliminateColinearAttributes()
          Get the value of EliminateColinearAttributes.
Returns:
Value of EliminateColinearAttributes.
 o setEliminateColinearAttributes
public void setEliminateColinearAttributes(boolean newEliminateColinearAttributes)
          Set the value of EliminateColinearAttributes.
Parameters:
newEliminateColinearAttributes - Value to assign to EliminateColinearAttributes.
 o numParameters
public int numParameters()
          Get the number of coefficients used in the model
Returns:
the number of coefficients
 o setAttributeSelectionMethod
public void setAttributeSelectionMethod(SelectedTag method)
          Sets the method used to select attributes for use in the linear regression.
Parameters:
method - the attribute selection method to use.
 o getAttributeSelectionMethod
public SelectedTag getAttributeSelectionMethod()
          Gets the method used to select attributes for use in the linear regression.
Returns:
the method to use.
 o setDebug
public void setDebug(boolean debug)
          Controls whether debugging output will be printed
Parameters:
debug - true if debugging output should be printed
 o getDebug
public boolean getDebug()
          Controls whether debugging output will be printed
Parameters:
debug - true if debugging output should be printed
 o main
public static void main(java.lang.String argv[])
          Generates a linear regression function predictor.
Parameters:
String - the options

All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home