All Packages Class Hierarchy This Package Previous Next Index WEKA's home
Class weka.classifiers.Bagging
java.lang.Object
|
+----weka.classifiers.Classifier
|
+----weka.classifiers.DistributionClassifier
|
+----weka.classifiers.Bagging
- public class Bagging
- extends DistributionClassifier
- implements OptionHandler
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).
Options after -- are passed to the designated classifier.
- Version:
- $Revision: 1.14 $
- Author:
- Eibe Frank (eibe@cs.waikato.ac.nz)
- Author:
- Len Trigg (len@intelligenesis.net)
Bagging()
-
buildClassifier(Instances)
- Bagging method.
distributionForInstance(Instance)
- Calculates the class membership probabilities for the given test instance.
getBagSizePercent()
- Gets the size of each bag, as a percentage of the training set size.
getClassifier()
- Get the classifier used as the classifier
getNumIterations()
- Gets the number of bagging iterations
getOptions()
- Gets the current settings of the Classifier.
getSeed()
- Gets the seed for the random number generations
listOptions()
- Returns an enumeration describing the available options
main(String[])
- Main method for testing this class.
setBagSizePercent(int)
- Sets the size of each bag, as a percentage of the training set size.
setClassifier(Classifier)
- Set the classifier for bagging.
setNumIterations(int)
- Sets the number of bagging iterations
setOptions(String[])
- Parses a given list of options.
setSeed(int)
- Set the seed for random number generation.
toString()
- Returns description of the bagged classifier.
Bagging
public Bagging()
listOptions
public java.util.Enumeration listOptions()
Returns an enumeration describing the available options
- Returns:
- an enumeration of all the available options
setOptions
public void setOptions(java.lang.String options[]) throws java.lang.Exception
Parses a given list of options. 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).
Options after -- are passed to the designated classifier.
- Parameters:
options
- the list of options as an array of strings
- Throws:
- java.lang.Exception - if an option is not supported
getOptions
public java.lang.String[] getOptions()
Gets the current settings of the Classifier.
- Returns:
- an array of strings suitable for passing to setOptions
setClassifier
public void setClassifier(Classifier newClassifier)
Set the classifier for bagging.
- Parameters:
newClassifier
- the Classifier to use.
getClassifier
public Classifier getClassifier()
Get the classifier used as the classifier
- Returns:
- the classifier used as the classifier
getBagSizePercent
public int getBagSizePercent()
Gets the size of each bag, as a percentage of the training set size.
- Returns:
- the bag size, as a percentage.
setBagSizePercent
public void setBagSizePercent(int newBagSizePercent)
Sets the size of each bag, as a percentage of the training set size.
- Parameters:
newBagSizePercent
- the bag size, as a percentage.
setNumIterations
public void setNumIterations(int numIterations)
Sets the number of bagging iterations
getNumIterations
public int getNumIterations()
Gets the number of bagging iterations
- Returns:
- the maximum number of bagging iterations
setSeed
public void setSeed(int seed)
Set the seed for random number generation.
- Parameters:
seed
- the seed
getSeed
public int getSeed()
Gets the seed for the random number generations
- Returns:
- the seed for the random number generation
buildClassifier
public void buildClassifier(Instances data) throws java.lang.Exception
Bagging method.
- Parameters:
data
- the training data to be used for generating the
bagged classifier.
- Throws:
- java.lang.Exception - if the classifier could not be built successfully
- Overrides:
- buildClassifier in class Classifier
distributionForInstance
public double[] distributionForInstance(Instance instance) throws java.lang.Exception
Calculates the class membership probabilities for the given test instance.
- Parameters:
instance
- the instance to be classified
- Returns:
- preedicted class probability distribution
- Throws:
- java.lang.Exception - if distribution can't be computed successfully
- Overrides:
- distributionForInstance in class DistributionClassifier
toString
public java.lang.String toString()
Returns description of the bagged classifier.
- Returns:
- description of the bagged classifier as a string
- Overrides:
- toString in class java.lang.Object
main
public static void main(java.lang.String argv[])
Main method for testing this class.
- Parameters:
argv
- the options
All Packages Class Hierarchy This Package Previous Next Index WEKA's home