Package weka.classifiers.functions
Class SimpleLinearRegressionWithAccess
- java.lang.Object
-
- weka.classifiers.AbstractClassifier
-
- weka.classifiers.functions.SimpleLinearRegressionWithAccess
-
- All Implemented Interfaces:
Serializable,Cloneable,weka.classifiers.Classifier,weka.core.BatchPredictor,weka.core.CapabilitiesHandler,weka.core.CapabilitiesIgnorer,weka.core.CommandlineRunnable,weka.core.OptionHandler,weka.core.RevisionHandler,weka.core.WeightedInstancesHandler
- Direct Known Subclasses:
SimpleLinearRegressionIntervalEstimator
public class SimpleLinearRegressionWithAccess extends weka.classifiers.AbstractClassifier implements weka.core.WeightedInstancesHandlerLearns a simple linear regression model. Picks the attribute that results in the lowest squared error. Can only deal with numeric attributes.
Makes standard errors available. 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: 11130 $
- Author:
- Eibe Frank ([email protected])
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected weka.core.Attributem_attributeThe chosen attributeprotected intm_attributeIndexThe index of the chosen attributeprotected doublem_classMeanForMissingThe class mean for missing valuesprotected intm_dfDegrees of freedom, used in statistical calculationsprotected doublem_fstatF-statistic for the regressionprotected doublem_interceptThe interceptprotected booleanm_outputAdditionalStatsWhether to output additional statistics such as std. dev. of coefficients and t-statsprotected doublem_rsquaredR^2 value for the regressionprotected doublem_rsquaredAdjAdjusted R^2 value for the regressionprotected doublem_seInterceptstandard error of the interceptprotected doublem_seSlopestandard error of the slopeprotected doublem_slopeThe slopeprotected booleanm_suppressErrorMessageIf true, suppress error message if no useful attribute was foundprotected doublem_tstatInterceptt-statistic of the interceptprotected doublem_tstatSlopet-statistic of the slope
-
Constructor Summary
Constructors Constructor Description SimpleLinearRegressionWithAccess()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbuildClassifier(weka.core.Instances insts)Builds a simple linear regression model given the supplied training data.doubleclassifyInstance(weka.core.Instance inst)Generate a prediction for the supplied instance.booleanfoundUsefulAttribute()Returns true if a usable attribute was found.intgetAttributeIndex()Returns the index of the attribute used in the regression.weka.core.CapabilitiesgetCapabilities()Returns default capabilities of the classifier.doublegetIntercept()Returns the intercept of the function.doublegetInterceptSE()Returns the standard error intercept of the function.String[]getOptions()Gets the current settings of the classifier.booleangetOutputAdditionalStats()Get whether to output additional statistics (such as std. deviation of coefficients and t-statisticsStringgetRevision()Returns the revision string.doublegetSlope()Returns the slope of the function.doublegetSlopeSE()Returns the standard error of slope of the function.StringglobalInfo()Returns a string describing this classifierEnumeration<weka.core.Option>listOptions()Returns an enumeration describing the available options.static voidmain(String[] argv)Main method for testing this classStringoutputAdditionalStatsTipText()Returns the tip text for this property.voidsetOptions(String[] options)Parses a given list of options.voidsetOutputAdditionalStats(boolean additional)Set whether to output additional statistics (such as std. deviation of coefficients and t-statisticsvoidsetSuppressErrorMessage(boolean s)Turn off the error message that is reported when no useful attribute is found.StringtoString()Returns a description of this classifier as a string-
Methods 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
-
-
-
-
Field Detail
-
m_attribute
protected weka.core.Attribute m_attribute
The chosen attribute
-
m_attributeIndex
protected int m_attributeIndex
The index of the chosen attribute
-
m_slope
protected double m_slope
The slope
-
m_intercept
protected double m_intercept
The intercept
-
m_classMeanForMissing
protected double m_classMeanForMissing
The class mean for missing values
-
m_outputAdditionalStats
protected boolean m_outputAdditionalStats
Whether to output additional statistics such as std. dev. of coefficients and t-stats
-
m_df
protected int m_df
Degrees of freedom, used in statistical calculations
-
m_seSlope
protected double m_seSlope
standard error of the slope
-
m_seIntercept
protected double m_seIntercept
standard error of the intercept
-
m_tstatSlope
protected double m_tstatSlope
t-statistic of the slope
-
m_tstatIntercept
protected double m_tstatIntercept
t-statistic of the intercept
-
m_rsquared
protected double m_rsquared
R^2 value for the regression
-
m_rsquaredAdj
protected double m_rsquaredAdj
Adjusted R^2 value for the regression
-
m_fstat
protected double m_fstat
F-statistic for the regression
-
m_suppressErrorMessage
protected boolean m_suppressErrorMessage
If true, suppress error message if no useful attribute was found
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing this classifier- Returns:
- a description of the classifier suitable for displaying in the explorer/experimenter gui
-
listOptions
public Enumeration<weka.core.Option> listOptions()
Returns an enumeration describing the available options.- Specified by:
listOptionsin interfaceweka.core.OptionHandler- Overrides:
listOptionsin classweka.classifiers.AbstractClassifier- Returns:
- an enumeration of all the available options.
-
setOptions
public void setOptions(String[] options) throws Exception
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:
setOptionsin interfaceweka.core.OptionHandler- Overrides:
setOptionsin classweka.classifiers.AbstractClassifier- Parameters:
options- the list of options as an array of strings- Throws:
Exception- if an option is not supported
-
getOptions
public String[] getOptions()
Gets the current settings of the classifier.- Specified by:
getOptionsin interfaceweka.core.OptionHandler- Overrides:
getOptionsin classweka.classifiers.AbstractClassifier- Returns:
- an array of strings suitable for passing to setOptions
-
outputAdditionalStatsTipText
public String 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
public double classifyInstance(weka.core.Instance inst) throws ExceptionGenerate a prediction for the supplied instance.- Specified by:
classifyInstancein interfaceweka.classifiers.Classifier- Overrides:
classifyInstancein classweka.classifiers.AbstractClassifier- Parameters:
inst- the instance to predict.- Returns:
- the prediction
- Throws:
Exception- if an error occurs
-
getCapabilities
public weka.core.Capabilities getCapabilities()
Returns default capabilities of the classifier.- Specified by:
getCapabilitiesin interfaceweka.core.CapabilitiesHandler- Specified by:
getCapabilitiesin interfaceweka.classifiers.Classifier- Overrides:
getCapabilitiesin classweka.classifiers.AbstractClassifier- Returns:
- the capabilities of this classifier
-
buildClassifier
public void buildClassifier(weka.core.Instances insts) throws ExceptionBuilds a simple linear regression model given the supplied training data.- Specified by:
buildClassifierin interfaceweka.classifiers.Classifier- 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.
-
getSlopeSE
public double getSlopeSE()
Returns the standard error of slope of the function.- Returns:
- the SE of the slope.
-
getIntercept
public double getIntercept()
Returns the intercept of the function.- Returns:
- the intercept.
-
getInterceptSE
public double getInterceptSE()
Returns the standard error intercept of the function.- Returns:
- the standard error of 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 String toString()
Returns a description of this classifier as a string
-
getRevision
public String getRevision()
Returns the revision string.- Specified by:
getRevisionin interfaceweka.core.RevisionHandler- Overrides:
getRevisionin classweka.classifiers.AbstractClassifier- Returns:
- the revision
-
main
public static void main(String[] argv)
Main method for testing this class- Parameters:
argv- options
-
-