|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--weka.classifiers.Classifier | +--weka.classifiers.DistributionClassifier | +--weka.classifiers.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).
Options after -- are passed to the designated classifier.
Field Summary | |
protected int |
m_BagSizePercent
The size of each bag sample, as a percentage of the training size |
protected Classifier |
m_Classifier
The model base classifier to use |
protected Classifier[] |
m_Classifiers
Array for storing the generated base classifiers. |
protected int |
m_NumIterations
The number of iterations. |
protected int |
m_Seed
The seed for random number generation. |
Constructor Summary | |
Bagging()
|
Method Summary | |
void |
buildClassifier(Instances data)
Bagging method. |
double[] |
distributionForInstance(Instance instance)
Calculates the class membership probabilities for the given test instance. |
int |
getBagSizePercent()
Gets the size of each bag, as a percentage of the training set size. |
Classifier |
getClassifier()
Get the classifier used as the classifier |
int |
getNumIterations()
Gets the number of bagging iterations |
java.lang.String[] |
getOptions()
Gets the current settings of the Classifier. |
int |
getSeed()
Gets the seed for the random number generations |
java.util.Enumeration |
listOptions()
Returns an enumeration describing the available options |
static void |
main(java.lang.String[] argv)
Main method for testing this class. |
void |
setBagSizePercent(int newBagSizePercent)
Sets the size of each bag, as a percentage of the training set size. |
void |
setClassifier(Classifier newClassifier)
Set the classifier for bagging. |
void |
setNumIterations(int numIterations)
Sets the number of bagging iterations |
void |
setOptions(java.lang.String[] options)
Parses a given list of options. |
void |
setSeed(int seed)
Set the seed for random number generation. |
java.lang.String |
toString()
Returns description of the bagged classifier. |
Methods inherited from class weka.classifiers.DistributionClassifier |
classifyInstance |
Methods inherited from class weka.classifiers.Classifier |
forName, makeCopies |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected Classifier m_Classifier
protected Classifier[] m_Classifiers
protected int m_NumIterations
protected int m_Seed
protected int m_BagSizePercent
Constructor Detail |
public Bagging()
Method Detail |
public java.util.Enumeration listOptions()
listOptions
in interface OptionHandler
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).
Options after -- are passed to the designated classifier.
setOptions
in interface OptionHandler
options
- the list of options as an array of stringsjava.lang.Exception
- if an option is not supportedpublic java.lang.String[] getOptions()
getOptions
in interface OptionHandler
public void setClassifier(Classifier newClassifier)
newClassifier
- the Classifier to use.public Classifier getClassifier()
public int getBagSizePercent()
public void setBagSizePercent(int newBagSizePercent)
newBagSizePercent
- the bag size, as a percentage.public void setNumIterations(int numIterations)
public int getNumIterations()
public void setSeed(int seed)
seed
- the seedpublic int getSeed()
public void buildClassifier(Instances data) throws java.lang.Exception
buildClassifier
in class Classifier
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 DistributionClassifier
instance
- the instance to be classifiedjava.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: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |