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)

Constructor Index

 o Bagging()
 

Method Index

 o buildClassifier(Instances)
Bagging method.
 o distributionForInstance(Instance)
Calculates the class membership probabilities for the given test instance.
 o getBagSizePercent()
Gets the size of each bag, as a percentage of the training set size.
 o getClassifier()
Get the classifier used as the classifier
 o getNumIterations()
Gets the number of bagging iterations
 o getOptions()
Gets the current settings of the Classifier.
 o getSeed()
Gets the seed for the random number generations
 o listOptions()
Returns an enumeration describing the available options
 o main(String[])
Main method for testing this class.
 o setBagSizePercent(int)
Sets the size of each bag, as a percentage of the training set size.
 o setClassifier(Classifier)
Set the classifier for bagging.
 o setNumIterations(int)
Sets the number of bagging iterations
 o setOptions(String[])
Parses a given list of options.
 o setSeed(int)
Set the seed for random number generation.
 o toString()
Returns description of the bagged classifier.

Constructor Detail

 o Bagging
public Bagging()

Method Detail

 o listOptions
public java.util.Enumeration listOptions()
          Returns an enumeration describing the available options
Returns:
an enumeration of all the available options
 o 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
 o getOptions
public java.lang.String[] getOptions()
          Gets the current settings of the Classifier.
Returns:
an array of strings suitable for passing to setOptions
 o setClassifier
public void setClassifier(Classifier newClassifier)
          Set the classifier for bagging.
Parameters:
newClassifier - the Classifier to use.
 o getClassifier
public Classifier getClassifier()
          Get the classifier used as the classifier
Returns:
the classifier used as the classifier
 o 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.
 o 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.
 o setNumIterations
public void setNumIterations(int numIterations)
          Sets the number of bagging iterations
 o getNumIterations
public int getNumIterations()
          Gets the number of bagging iterations
Returns:
the maximum number of bagging iterations
 o setSeed
public void setSeed(int seed)
          Set the seed for random number generation.
Parameters:
seed - the seed
 o getSeed
public int getSeed()
          Gets the seed for the random number generations
Returns:
the seed for the random number generation
 o 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
 o 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
 o 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
 o 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