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 boosting (required).

-I num
Set the number of bagging iterations (default 10).

-S seed
Random number seed for resampling (default 1).

Options after -- are passed to the designated classifier.

Version:
$Revision: 1.8 $
Author:
Eibe Frank (eibe@cs.waikato.ac.nz)

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 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 setClassifier(Classifier)
Set the classifier for boosting.
 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.

Constructors

 o Bagging
 public Bagging()

Methods

 o listOptions
 public Enumeration listOptions()
Returns an enumeration describing the available options

Returns:
an enumeration of all the available options
 o setOptions
 public void setOptions(String options[]) throws 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 boosting (required).

-I num
Set the number of bagging iterations (default 10).

-S seed
Random number seed for resampling (default 1).

Options after -- are passed to the designated classifier.

Parameters:
options - the list of options as an array of strings
Throws: Exception
if an option is not supported
 o getOptions
 public 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 boosting.

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 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 Exception
Bagging method.

Parameters:
data - the training data to be used for generating the bagged classifier.
Throws: Exception
if the classifier could not be built successfully
Overrides:
buildClassifier in class Classifier
 o distributionForInstance
 public double[] distributionForInstance(Instance instance) throws Exception
Calculates the class membership probabilities for the given test instance.

Parameters:
instance - the instance to be classified
Returns:
preedicted class probability distribution
Throws: Exception
if distribution can't be computed successfully
Overrides:
distributionForInstance in class DistributionClassifier
 o toString
 public String toString()
Returns description of the bagged classifier.

Returns:
description of the bagged classifier as a string
Overrides:
toString in class Object
 o main
 public static void main(String argv[])
Main method for testing this class.

Parameters:
argv - the options

All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home