Package weka.classifiers.functions
Class SimpleLinearRegression
java.lang.Object
weka.classifiers.AbstractClassifier
weka.classifiers.functions.SimpleLinearRegression
- All Implemented Interfaces:
Serializable
,Cloneable
,Classifier
,BatchPredictor
,CapabilitiesHandler
,CapabilitiesIgnorer
,CommandlineRunnable
,OptionHandler
,RevisionHandler
,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: 15519 $
- Author:
- Eibe Frank (eibe@cs.waikato.ac.nz)
- See Also:
-
Field Summary
Fields inherited from class weka.classifiers.AbstractClassifier
BATCH_SIZE_DEFAULT, NUM_DECIMAL_PLACES_DEFAULT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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
Returns true if a usable attribute was found.int
Returns the index of the attribute used in the regression.Returns default capabilities of the classifier.double
Returns the intercept of the function.String[]
Gets the current settings of the classifier.boolean
Get whether to output additional statistics (such as std.Returns the revision string.double
getSlope()
Returns the slope of the function.Returns a string describing this classifierReturns an enumeration describing the available options.static void
Main method for testing this classReturns 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.toString()
Returns a description of this classifier as a stringMethods 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
-
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
-
listOptions
Returns an enumeration describing the available options.- Specified by:
listOptions
in interfaceOptionHandler
- Overrides:
listOptions
in classAbstractClassifier
- Returns:
- an enumeration of all the available options.
-
setOptions
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 interfaceOptionHandler
- Overrides:
setOptions
in classAbstractClassifier
- Parameters:
options
- the list of options as an array of strings- Throws:
Exception
- if an option is not supported
-
getOptions
Gets the current settings of the classifier.- Specified by:
getOptions
in interfaceOptionHandler
- Overrides:
getOptions
in classAbstractClassifier
- Returns:
- an array of strings suitable for passing to setOptions
-
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
Generate a prediction for the supplied instance.- Specified by:
classifyInstance
in interfaceClassifier
- Overrides:
classifyInstance
in classAbstractClassifier
- Parameters:
inst
- the instance to predict.- Returns:
- the prediction
- Throws:
Exception
- if an error occurs
-
getCapabilities
Returns default capabilities of the classifier.- Specified by:
getCapabilities
in interfaceCapabilitiesHandler
- Specified by:
getCapabilities
in interfaceClassifier
- Overrides:
getCapabilities
in classAbstractClassifier
- Returns:
- the capabilities of this classifier
- See Also:
-
buildClassifier
Builds a simple linear regression model given the supplied training data.- Specified by:
buildClassifier
in interfaceClassifier
- 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:
getRevision
in interfaceRevisionHandler
- Overrides:
getRevision
in classAbstractClassifier
- Returns:
- the revision
-
main
Main method for testing this class- Parameters:
argv
- options
-