All Packages Class Hierarchy This Package Previous Next Index WEKA's home
Class weka.classifiers.LinearRegression
java.lang.Object
|
+----weka.classifiers.Classifier
|
+----weka.classifiers.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)
- Version:
- $Revision: 1.12 $
- Author:
- Eibe Frank (eibe@cs.waikato.ac.nz)
- Author:
- Len Trigg (trigg@cs.waikato.ac.nz)
TAGS_SELECTION-
LinearRegression()
-
buildClassifier(Instances)
- Builds a regression model for the given data.
classifyInstance(Instance)
- Classifies the given instance using the linear regression function.
getAttributeSelectionMethod()
- Gets the method used to select attributes for use in the
linear regression.
getDebug()
- Controls whether debugging output will be printed
getOptions()
- Gets the current settings of the classifier.
listOptions()
- Returns an enumeration describing the available options
main(String[])
- Generates a linear regression function predictor.
numParameters()
- Get the number of coefficients used in the model
setAttributeSelectionMethod(SelectedTag)
- Sets the method used to select attributes for use in the
linear regression.
setDebug(boolean)
- Controls whether debugging output will be printed
setOptions(String[])
- Parses a given list of options.
toString()
- Outputs the linear regression model as a string.
TAGS_SELECTION
public static final Tag[] TAGS_SELECTION
LinearRegression
public LinearRegression()
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
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
toString
public java.lang.String toString()
Outputs the linear regression model as a string.
- Overrides:
- toString in class java.lang.Object
listOptions
public java.util.Enumeration listOptions()
Returns an enumeration describing the available options
- 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:
-D
Produce debugging output.
-S num
Set the attriute selection method to use. 1 = None, 2 = Greedy
(default 0 = M5' method)
- 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.
- Returns:
- an array of strings suitable for passing to setOptions
numParameters
public int numParameters()
Get the number of coefficients used in the model
- Returns:
- the number of coefficients
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.
getAttributeSelectionMethod
public SelectedTag getAttributeSelectionMethod()
Gets the method used to select attributes for use in the
linear regression.
- Returns:
- the method to use.
setDebug
public void setDebug(boolean debug)
Controls whether debugging output will be printed
- Parameters:
debug
- true if debugging output should be printed
getDebug
public boolean getDebug()
Controls whether debugging output will be printed
- Parameters:
debug
- true if debugging output should be printed
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