Package weka.classifiers.functions
Class SimpleLinearRegression
java.lang.Object
weka.classifiers.Classifier
weka.classifiers.functions.SimpleLinearRegression
- All Implemented Interfaces:
Serializable,Cloneable,CapabilitiesHandler,OptionHandler,RevisionHandler,WeightedInstancesHandler
Learns a simple linear regression model. Picks the attribute that results in the lowest squared error. Missing values are not allowed. Can only deal with numeric attributes.
Valid options are:
-D If set, classifier is run in debug mode and may output additional info to the console
- Version:
- $Revision: 5523 $
- Author:
- Eibe Frank (eibe@cs.waikato.ac.nz)
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbuildClassifier(Instances insts) Builds a simple linear regression model given the supplied training data.doubleclassifyInstance(Instance inst) Generate a prediction for the supplied instance.booleanReturns true if a usable attribute was found.intReturns the index of the attribute used in the regression.Returns default capabilities of the classifier.doubleReturns the intercept of the function.Returns the revision string.doublegetSlope()Returns the slope of the function.Returns a string describing this classifierstatic voidMain method for testing this classvoidsetSuppressErrorMessage(boolean s) Turn off the error message that is reported when no useful attribute is found.toString()Returns a description of this classifier as a stringMethods inherited from class weka.classifiers.Classifier
debugTipText, distributionForInstance, forName, getDebug, getOptions, listOptions, makeCopies, makeCopy, setDebug, setOptions
-
Constructor Details
-
SimpleLinearRegression
public SimpleLinearRegression()
-
-
Method Details
-
globalInfo
Returns a string describing this classifier- Returns:
- a description of the classifier suitable for displaying in the explorer/experimenter gui
-
classifyInstance
Generate a prediction for the supplied instance.- Overrides:
classifyInstancein classClassifier- Parameters:
inst- the instance to predict.- Returns:
- the prediction
- Throws:
Exception- if an error occurs
-
getCapabilities
Returns default capabilities of the classifier.- Specified by:
getCapabilitiesin interfaceCapabilitiesHandler- Overrides:
getCapabilitiesin classClassifier- Returns:
- the capabilities of this classifier
- See Also:
-
buildClassifier
Builds a simple linear regression model given the supplied training data.- Specified by:
buildClassifierin classClassifier- 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.
-
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
Returns a description of this classifier as a string -
getRevision
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Overrides:
getRevisionin classClassifier- Returns:
- the revision
-
main
Main method for testing this class- Parameters:
argv- options
-