|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.classifiers.Classifier
weka.classifiers.DistributionClassifier
weka.classifiers.EnsembleClassifier
weka.classifiers.meta.QBag
This class implements Query-by-Bagging based on Abe and Mamitsuka (ICML 98). Built on class for bagging a classifier. For more information, see
Leo Breiman (1996). QBag 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 boolean |
m_Debug
Set to true to get debugging output. |
protected boolean |
m_HardVoteAssignment
Set true to use hard assignment for ensemble member votes |
protected int |
m_NumIterations
The number of iterations. |
protected int |
m_Seed
The seed for random number generation. |
Fields inherited from class weka.classifiers.EnsembleClassifier |
m_EnsembleWts, m_SumEnsembleWts, m_TrainEnsembleDiversity, m_TrainEnsembleError, m_TrainError |
Constructor Summary | |
QBag()
|
Method Summary | |
void |
buildClassifier(Instances data)
QBag 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 |
double[] |
getEnsemblePredictions(Instance instance)
Returns class predictions of each ensemble member |
double |
getEnsembleSize()
Returns size of ensemble |
double[] |
getEnsembleWts()
Returns vote weights of ensemble members. |
boolean |
getHardVoteAssignment()
Get the value of m_HardVoteAssignment. |
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. |
int[] |
selectInstances(Instances unlabeledActivePool,
int num)
Given a set of unlabeled examples, select a specified number of examples to be labeled. |
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 |
setHardVoteAssignment(boolean v)
Set the value of m_HardVoteAssignment. |
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.EnsembleClassifier |
computeEnsembleMeasures, enumerateMeasures, getMeasure, initMeasures, measureTrainEnsembleDiversity, measureTrainEnsembleError, measureTrainError, updateEnsembleStats |
Methods inherited from class weka.classifiers.DistributionClassifier |
calculateEntropy, calculateLabeledInstanceMargin, calculateMargin, 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 boolean m_HardVoteAssignment
protected boolean m_Debug
protected Classifier m_Classifier
protected Classifier[] m_Classifiers
protected int m_NumIterations
protected int m_Seed
protected int m_BagSizePercent
Constructor Detail |
public QBag()
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 strings
java.lang.Exception
- if an option is not supportedpublic java.lang.String[] getOptions()
getOptions
in interface OptionHandler
public boolean getHardVoteAssignment()
public void setHardVoteAssignment(boolean v)
v
- Value to assign to m_HardVoteAssignment.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 classified
java.lang.Exception
- if distribution can't be computed successfullypublic int[] selectInstances(Instances unlabeledActivePool, int num) throws java.lang.Exception
selectInstances
in interface ActiveLearner
unlabeledActivePool
- pool of unlabeled examplesnum
- number of examples to selected for labeling
java.lang.Exception
- if selective sampling failspublic double[] getEnsemblePredictions(Instance instance) throws java.lang.Exception
getEnsemblePredictions
in class EnsembleClassifier
java.lang.Exception
public double[] getEnsembleWts()
getEnsembleWts
in class EnsembleClassifier
public double getEnsembleSize()
getEnsembleSize
in class EnsembleClassifier
public java.lang.String toString()
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 |