SimpleLinearRegression (original) (raw)
java.lang.Object
- weka.classifiers.Classifier
- weka.classifiers.functions.SimpleLinearRegression
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, CapabilitiesHandler, OptionHandler, RevisionHandler, WeightedInstancesHandler
public class SimpleLinearRegression
extends Classifier
implements 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:5523Revision: 5523 Revision:5523
Author:
Eibe Frank (eibe@cs.waikato.ac.nz)
See Also:
Serialized Form
Constructor Summary
Constructors
Constructor and Description SimpleLinearRegression() Method Summary
All Methods Static Methods Instance Methods Concrete Methods
Modifier and Type Method and Description void 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 foundUsefulAttribute() Returns true if a usable attribute was found. int getAttributeIndex() Returns the index of the attribute used in the regression. Capabilities getCapabilities() Returns default capabilities of the classifier. double getIntercept() Returns the intercept of the function. java.lang.String getRevision() Returns the revision string. double getSlope() Returns the slope of the function. java.lang.String globalInfo() Returns a string describing this classifier static void main(java.lang.String[] argv) Main method for testing this class void setSuppressErrorMessage(boolean s) Turn off the error message that is reported when no useful attribute is found. java.lang.String toString() Returns a description of this classifier as a string * ### Methods inherited from class weka.classifiers.[Classifier](../../../weka/classifiers/Classifier.html "class in weka.classifiers") `[debugTipText](../../../weka/classifiers/Classifier.html#debugTipText--), [distributionForInstance](../../../weka/classifiers/Classifier.html#distributionForInstance-weka.core.Instance-), [forName](../../../weka/classifiers/Classifier.html#forName-java.lang.String-java.lang.String:A-), [getDebug](../../../weka/classifiers/Classifier.html#getDebug--), [getOptions](../../../weka/classifiers/Classifier.html#getOptions--), [listOptions](../../../weka/classifiers/Classifier.html#listOptions--), [makeCopies](../../../weka/classifiers/Classifier.html#makeCopies-weka.classifiers.Classifier-int-), [makeCopy](../../../weka/classifiers/Classifier.html#makeCopy-weka.classifiers.Classifier-), [setDebug](../../../weka/classifiers/Classifier.html#setDebug-boolean-), [setOptions](../../../weka/classifiers/Classifier.html#setOptions-java.lang.String:A-)` * ### Methods inherited from class java.lang.Object `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`
Constructor Detail
* #### SimpleLinearRegression public SimpleLinearRegression()
Method Detail
* #### globalInfo public java.lang.String globalInfo() Returns a string describing this classifier Returns: a description of the classifier suitable for displaying in the explorer/experimenter gui * #### classifyInstance public double classifyInstance([Instance](../../../weka/core/Instance.html "class in weka.core") inst) throws java.lang.Exception Generate a prediction for the supplied instance. Overrides: `[classifyInstance](../../../weka/classifiers/Classifier.html#classifyInstance-weka.core.Instance-)` in class `[Classifier](../../../weka/classifiers/Classifier.html "class in weka.classifiers")` Parameters: `inst` \- the instance to predict. Returns: the prediction Throws: `java.lang.Exception` \- if an error occurs * #### getCapabilities public [Capabilities](../../../weka/core/Capabilities.html "class in weka.core") getCapabilities() Returns default capabilities of the classifier. Specified by: `[getCapabilities](../../../weka/core/CapabilitiesHandler.html#getCapabilities--)` in interface `[CapabilitiesHandler](../../../weka/core/CapabilitiesHandler.html "interface in weka.core")` Overrides: `[getCapabilities](../../../weka/classifiers/Classifier.html#getCapabilities--)` in class `[Classifier](../../../weka/classifiers/Classifier.html "class in weka.classifiers")` Returns: the capabilities of this classifier See Also: [Capabilities](../../../weka/core/Capabilities.html "class in weka.core") * #### buildClassifier public void buildClassifier([Instances](../../../weka/core/Instances.html "class in weka.core") insts) throws java.lang.Exception Builds a simple linear regression model given the supplied training data. Specified by: `[buildClassifier](../../../weka/classifiers/Classifier.html#buildClassifier-weka.core.Instances-)` in class `[Classifier](../../../weka/classifiers/Classifier.html "class in weka.classifiers")` Parameters: `insts` \- the training data. Throws: `java.lang.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 public java.lang.String toString() Returns a description of this classifier as a string Overrides: `toString` in class `java.lang.Object` Returns: a description of the classifier. * #### getRevision public java.lang.String getRevision() Returns the revision string. Specified by: `[getRevision](../../../weka/core/RevisionHandler.html#getRevision--)` in interface `[RevisionHandler](../../../weka/core/RevisionHandler.html "interface in weka.core")` Overrides: `[getRevision](../../../weka/classifiers/Classifier.html#getRevision--)` in class `[Classifier](../../../weka/classifiers/Classifier.html "class in weka.classifiers")` Returns: the revision * #### main public static void main(java.lang.String[] argv) Main method for testing this class Parameters: `argv` \- options