|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--weka.classifiers.Classifier | +--weka.classifiers.SingleClassifierEnhancer | +--weka.classifiers.IteratedSingleClassifierEnhancer | +--weka.classifiers.RandomizableIteratedSingleClassifierEnhancer | +--weka.classifiers.meta.Bagging
Class for bagging a classifier. For more information, see
Leo Breiman (1996). Bagging predictors. Machine Learning, 24(2):123-140.
Valid options are:
-W classname
Specify the full class name of a weak classifier as the basis for
bagging (required).
-I num
Set the number of bagging iterations (default 10).
-S seed
Random number seed for resampling (default 1).
-P num
Size of each bag, as a percentage of the training size (default 100).
-O
Compute out of bag error.
Options after -- are passed to the designated classifier.
Constructor Summary | |
Bagging()
Constructor. |
Method Summary | |
java.lang.String |
bagSizePercentTipText()
Returns the tip text for this property |
void |
buildClassifier(Instances data)
Bagging method. |
java.lang.String |
calcOutOfBagTipText()
Returns the tip text for this property |
double[] |
distributionForInstance(Instance instance)
Calculates the class membership probabilities for the given test instance. |
java.util.Enumeration |
enumerateMeasures()
Returns an enumeration of the additional measure names. |
int |
getBagSizePercent()
Gets the size of each bag, as a percentage of the training set size. |
boolean |
getCalcOutOfBag()
Get whether the out of bag error is calculated. |
double |
getMeasure(java.lang.String additionalMeasureName)
Returns the value of the named measure. |
java.lang.String[] |
getOptions()
Gets the current settings of the Classifier. |
java.lang.String |
globalInfo()
Returns a string describing classifier |
java.util.Enumeration |
listOptions()
Returns an enumeration describing the available options. |
static void |
main(java.lang.String[] argv)
Main method for testing this class. |
double |
measureOutOfBagError()
Gets the out of bag error that was calculated as the classifier was built. |
Instances |
resampleWithWeights(Instances data,
java.util.Random random,
boolean[] sampled)
Creates a new dataset of the same size using random sampling with replacement according to the given weight vector. |
void |
setBagSizePercent(int newBagSizePercent)
Sets the size of each bag, as a percentage of the training set size. |
void |
setCalcOutOfBag(boolean calcOutOfBag)
Set whether the out of bag error is calculated. |
void |
setOptions(java.lang.String[] options)
Parses a given list of options. |
java.lang.String |
toString()
Returns description of the bagged classifier. |
Methods inherited from class weka.classifiers.RandomizableIteratedSingleClassifierEnhancer |
getSeed, seedTipText, setSeed |
Methods inherited from class weka.classifiers.IteratedSingleClassifierEnhancer |
getNumIterations, numIterationsTipText, setNumIterations |
Methods inherited from class weka.classifiers.SingleClassifierEnhancer |
classifierTipText, getClassifier, setClassifier |
Methods inherited from class weka.classifiers.Classifier |
classifyInstance, debugTipText, forName, getDebug, makeCopies, setDebug |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Bagging()
Method Detail |
public java.lang.String globalInfo()
public java.util.Enumeration listOptions()
listOptions
in interface OptionHandler
listOptions
in class RandomizableIteratedSingleClassifierEnhancer
public void setOptions(java.lang.String[] options) throws java.lang.Exception
-W classname
Specify the full class name of a weak classifier as the basis for
bagging (required).
-I num
Set the number of bagging iterations (default 10).
-S seed
Random number seed for resampling (default 1).
-P num
Size of each bag, as a percentage of the training size (default 100).
-O
Compute out of bag error.
Options after -- are passed to the designated classifier.
setOptions
in interface OptionHandler
setOptions
in class RandomizableIteratedSingleClassifierEnhancer
options
- the list of options as an array of strings
java.lang.Exception
- if an option is not supportedpublic java.lang.String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class RandomizableIteratedSingleClassifierEnhancer
public java.lang.String bagSizePercentTipText()
public int getBagSizePercent()
public void setBagSizePercent(int newBagSizePercent)
newBagSizePercent
- the bag size, as a percentage.public java.lang.String calcOutOfBagTipText()
public void setCalcOutOfBag(boolean calcOutOfBag)
calcOutOfBag
- whether to calculate the out of bag errorpublic boolean getCalcOutOfBag()
public double measureOutOfBagError()
public java.util.Enumeration enumerateMeasures()
enumerateMeasures
in interface AdditionalMeasureProducer
public double getMeasure(java.lang.String additionalMeasureName)
getMeasure
in interface AdditionalMeasureProducer
additionalMeasureName
- the name of the measure to query for its value
java.lang.IllegalArgumentException
- if the named measure is not supportedpublic final Instances resampleWithWeights(Instances data, java.util.Random random, boolean[] sampled)
data
- the data to be sampled fromrandom
- a random number generatorsampled
- indicating which instance has been sampled
java.lang.IllegalArgumentException
- if the weights array is of the wrong
length or contains negative weights.public void buildClassifier(Instances data) throws java.lang.Exception
buildClassifier
in class IteratedSingleClassifierEnhancer
data
- the training data to be used for generating the
bagged classifier.
java.lang.Exception
- if the classifier could not be built successfullypublic double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance
in class Classifier
instance
- the instance to be classified
java.lang.Exception
- if distribution can't be computed successfullypublic java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] argv)
argv
- the options
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright (c) 2003 David Lindsay, Computer Learning Research Centre, Dept. Computer Science, Royal Holloway, University of London