Package weka.classifiers.meta
Class AdditiveRegression
java.lang.Object
weka.classifiers.AbstractClassifier
weka.classifiers.SingleClassifierEnhancer
weka.classifiers.IteratedSingleClassifierEnhancer
weka.classifiers.meta.AdditiveRegression
- All Implemented Interfaces:
Serializable,Cloneable,Classifier,IterativeClassifier,AdditionalMeasureProducer,BatchPredictor,CapabilitiesHandler,CapabilitiesIgnorer,CommandlineRunnable,OptionHandler,RevisionHandler,TechnicalInformationHandler,WeightedInstancesHandler
public class AdditiveRegression
extends IteratedSingleClassifierEnhancer
implements OptionHandler, AdditionalMeasureProducer, WeightedInstancesHandler, TechnicalInformationHandler, IterativeClassifier
Meta classifier that enhances the performance of a regression base classifier. Each iteration fits a model to the residuals left by the classifier on the previous iteration. Prediction is accomplished by adding the predictions of each classifier. Reducing the shrinkage (learning rate) parameter helps prevent overfitting and has a smoothing effect but increases the learning time.
For more information see:
J.H. Friedman (1999). Stochastic Gradient Boosting. BibTeX:
For more information see:
J.H. Friedman (1999). Stochastic Gradient Boosting. BibTeX:
@techreport{Friedman1999,
author = {J.H. Friedman},
institution = {Stanford University},
title = {Stochastic Gradient Boosting},
year = {1999},
PS = {http://www-stat.stanford.edu/\~jhf/ftp/stobst.ps}
}
Valid options are:
-S Specify shrinkage rate. (default = 1.0, ie. no shrinkage)
-I <num> Number of iterations. (default 10)
-A Minimize absolute error instead of squared error (assumes that base learner minimizes absolute error).-D If set, classifier is run in debug mode and may output additional info to the console-W Full name of base classifier. (default: weka.classifiers.trees.DecisionStump)Options specific to classifier weka.classifiers.trees.DecisionStump:-D If set, classifier is run in debug mode and may output additional info to the console
- Version:
- $Revision: 15520 $
- Author:
- Mark Hall (mhall@cs.waikato.ac.nz)
- See Also:
-
Field Summary
Fields inherited from class weka.classifiers.AbstractClassifier
BATCH_SIZE_DEFAULT, NUM_DECIMAL_PLACES_DEFAULT -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor specifying DecisionStump as the classifierAdditiveRegression(Classifier classifier) Constructor which takes base classifier as argument. -
Method Summary
Modifier and TypeMethodDescriptionvoidbuildClassifier(Instances data) Method used to build the classifier.doubleclassifyInstance(Instance inst) Classify an instance.voiddone()Clean up.Returns an enumeration of the additional measure namesReturns default capabilities of the classifier.doublegetMeasure(String additionalMeasureName) Returns the value of the named measurebooleanGets whether absolute error is to be minimized.String[]Gets the current settings of the Classifier.booleanReturns true if the model is to be finalized (or has been finalized) after training.Returns the revision string.doubleGet the shrinkage rate.Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.Returns a string describing this attribute evaluatorvoidInitialize classifier.Returns an enumeration describing the available options.static voidMain method for testing this class.doublereturn the number of iterations (base classifiers) completedReturns the tip text for this propertybooleannext()Perform another iteration.Tool tip text for the resume propertyvoidsetMinimizeAbsoluteError(boolean f) Sets whether absolute error is to be minimized.voidsetOptions(String[] options) Parses a given list of options.voidsetResume(boolean resume) If called with argument true, then the next time done() is called the model is effectively "frozen" and no further iterations can be performedvoidsetShrinkage(double l) Set the shrinkage parameterReturns the tip text for this propertytoString()Returns textual description of the classifier.Methods inherited from class weka.classifiers.IteratedSingleClassifierEnhancer
getNumIterations, numIterationsTipText, setNumIterationsMethods inherited from class weka.classifiers.SingleClassifierEnhancer
classifierTipText, getClassifier, postExecution, preExecution, setClassifierMethods inherited from class weka.classifiers.AbstractClassifier
batchSizeTipText, debugTipText, distributionForInstance, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlacesMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface weka.classifiers.Classifier
distributionForInstance
-
Constructor Details
-
AdditiveRegression
public AdditiveRegression()Default constructor specifying DecisionStump as the classifier -
AdditiveRegression
Constructor which takes base classifier as argument.- Parameters:
classifier- the base classifier to use
-
-
Method Details
-
globalInfo
Returns a string describing this attribute evaluator- Returns:
- a description of the evaluator suitable for displaying in the explorer/experimenter gui
-
getTechnicalInformation
Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.- Specified by:
getTechnicalInformationin interfaceTechnicalInformationHandler- Returns:
- the technical information about this class
-
listOptions
Returns an enumeration describing the available options.- Specified by:
listOptionsin interfaceOptionHandler- Overrides:
listOptionsin classIteratedSingleClassifierEnhancer- Returns:
- an enumeration of all the available options.
-
setOptions
Parses a given list of options. Valid options are:-S Specify shrinkage rate. (default = 1.0, ie. no shrinkage)
-I <num> Number of iterations. (default 10)
-A Minimize absolute error instead of squared error (assumes that base learner minimizes absolute error).
-D If set, classifier is run in debug mode and may output additional info to the console
-W Full name of base classifier. (default: weka.classifiers.trees.DecisionStump)
Options specific to classifier weka.classifiers.trees.DecisionStump:
-D If set, classifier is run in debug mode and may output additional info to the console
- Specified by:
setOptionsin interfaceOptionHandler- Overrides:
setOptionsin classIteratedSingleClassifierEnhancer- 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:
getOptionsin interfaceOptionHandler- Overrides:
getOptionsin classIteratedSingleClassifierEnhancer- Returns:
- an array of strings suitable for passing to setOptions
-
shrinkageTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setShrinkage
public void setShrinkage(double l) Set the shrinkage parameter- Parameters:
l- the shrinkage rate.
-
getShrinkage
public double getShrinkage()Get the shrinkage rate.- Returns:
- the value of the learning rate
-
minimizeAbsoluteErrorTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setMinimizeAbsoluteError
public void setMinimizeAbsoluteError(boolean f) Sets whether absolute error is to be minimized.- Parameters:
f- true if absolute error is to be minimized.
-
getMinimizeAbsoluteError
public boolean getMinimizeAbsoluteError()Gets whether absolute error is to be minimized.- Returns:
- true if absolute error is to be minimized
-
resumeTipText
Tool tip text for the resume property- Returns:
- the tool tip text for the finalize property
-
setResume
public void setResume(boolean resume) If called with argument true, then the next time done() is called the model is effectively "frozen" and no further iterations can be performed- Specified by:
setResumein interfaceIterativeClassifier- Parameters:
resume- true if the model is to be finalized after performing iterations
-
getResume
public boolean getResume()Returns true if the model is to be finalized (or has been finalized) after training.- Specified by:
getResumein interfaceIterativeClassifier- Returns:
- the current value of finalize
-
getCapabilities
Returns default capabilities of the classifier.- Specified by:
getCapabilitiesin interfaceCapabilitiesHandler- Specified by:
getCapabilitiesin interfaceClassifier- Overrides:
getCapabilitiesin classSingleClassifierEnhancer- Returns:
- the capabilities of this classifier
- See Also:
-
buildClassifier
Method used to build the classifier.- Specified by:
buildClassifierin interfaceClassifier- Overrides:
buildClassifierin classIteratedSingleClassifierEnhancer- Parameters:
data- the training data to be used for generating the bagged classifier.- Throws:
Exception- if the classifier could not be built successfully
-
initializeClassifier
Initialize classifier.- Specified by:
initializeClassifierin interfaceIterativeClassifier- Parameters:
data- the training data- Throws:
Exception- if the classifier could not be initialized successfully
-
next
Perform another iteration.- Specified by:
nextin interfaceIterativeClassifier- Returns:
- false if no further iterations could be performed, true otherwise
- Throws:
Exception- if this iteration fails for unexpected reasons
-
done
public void done()Clean up.- Specified by:
donein interfaceIterativeClassifier
-
classifyInstance
Classify an instance.- Specified by:
classifyInstancein interfaceClassifier- Overrides:
classifyInstancein classAbstractClassifier- Parameters:
inst- the instance to predict- Returns:
- a prediction for the instance
- Throws:
Exception- if an error occurs
-
enumerateMeasures
Returns an enumeration of the additional measure names- Specified by:
enumerateMeasuresin interfaceAdditionalMeasureProducer- Returns:
- an enumeration of the measure names
-
getMeasure
Returns the value of the named measure- Specified by:
getMeasurein interfaceAdditionalMeasureProducer- Parameters:
additionalMeasureName- the name of the measure to query for its value- Returns:
- the value of the named measure
- Throws:
IllegalArgumentException- if the named measure is not supported
-
measureNumIterations
public double measureNumIterations()return the number of iterations (base classifiers) completed- Returns:
- the number of iterations (same as number of base classifier models)
-
toString
Returns textual description of the classifier. -
getRevision
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Overrides:
getRevisionin classAbstractClassifier- Returns:
- the revision
-
main
Main method for testing this class.- Parameters:
argv- should contain the following arguments: -t training file [-T test file] [-c class index]
-