|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--weka.classifiers.Classifier | +--weka.classifiers.Stacking
Implements stacking. For more information, see
David H. Wolpert (1992). Stacked generalization. Neural Networks, 5:241-259, Pergamon Press.
Valid options are:
-X num_folds
The number of folds for the cross-validation (default 10).
-S seed
Random number seed (default 1).
-B classifierstring
Classifierstring should contain the full class name of a base scheme
followed by options to the classifier.
(required, option should be used once for each classifier).
-M classifierstring
Classifierstring for the meta classifier. Same format as for base
classifiers. (required)
Field Summary | |
protected Classifier[] |
m_BaseClassifiers
The base classifiers. |
protected Instances |
m_BaseFormat
Format for base data |
protected Classifier |
m_MetaClassifier
The meta classifier. |
protected Instances |
m_MetaFormat
Format for meta data |
protected int |
m_NumFolds
Set the number of folds for the cross-validation |
protected int |
m_Seed
Random number seed |
Constructor Summary | |
Stacking()
|
Method Summary | |
void |
buildClassifier(Instances data)
Buildclassifier selects a classifier from the set of classifiers by minimising error on the training data. |
double |
classifyInstance(Instance instance)
Classifies a given instance using the stacked classifier. |
Classifier |
getBaseClassifier(int index)
Gets the specific classifier from the set of base classifiers. |
Classifier[] |
getBaseClassifiers()
Gets the list of possible classifers to choose from. |
protected java.lang.String |
getBaseClassifierSpec(int index)
Gets the classifier specification string, which contains the class name of the classifier and any options to the classifier |
protected java.lang.String |
getClassifierSpec(Classifier c)
Gets the classifier specification string, which contains the class name of the classifier and any options to the classifier |
Classifier |
getMetaClassifier()
Gets the meta classifier. |
int |
getNumFolds()
Gets the number of folds for the cross-validation. |
java.lang.String[] |
getOptions()
Gets the current settings of the Classifier. |
int |
getSeed()
Gets the random number seed. |
java.util.Enumeration |
listOptions()
Returns an enumeration describing the available options |
static void |
main(java.lang.String[] argv)
Main method for testing this class. |
protected Instances |
metaFormat(Instances instances)
Makes the format for the level-1 data. |
protected Instance |
metaInstance(Instance instance)
Makes a level-1 instance from the given instance. |
void |
setBaseClassifiers(Classifier[] classifiers)
Sets the list of possible classifers to choose from. |
void |
setMetaClassifier(Classifier classifier)
Adds meta classifier |
void |
setNumFolds(int numFolds)
Sets the number of folds for the cross-validation. |
void |
setOptions(java.lang.String[] options)
Parses a given list of options. |
void |
setSeed(int seed)
Sets the seed for random number generation. |
java.lang.String |
toString()
Output a representation of this classifier |
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_MetaClassifier
protected Classifier[] m_BaseClassifiers
protected Instances m_MetaFormat
protected Instances m_BaseFormat
protected int m_NumFolds
protected int m_Seed
Constructor Detail |
public Stacking()
Method Detail |
public java.util.Enumeration listOptions()
listOptions
in interface OptionHandler
public void setOptions(java.lang.String[] options) throws java.lang.Exception
-X num_folds
The number of folds for the cross-validation (default 10).
-S seed
Random number seed (default 1).
-B classifierstring
Classifierstring should contain the full class name of a base scheme
followed by options to the classifier.
(required, option should be used once for each classifier).
-M classifierstring
Classifierstring for the meta classifier. Same format as for base
classifiers. (required)
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 setSeed(int seed)
seed
- the random number seedpublic int getSeed()
public int getNumFolds()
public void setNumFolds(int numFolds) throws java.lang.Exception
numFolds
- the number of folds for the cross-validationjava.lang.Exception
- if parameter illegalpublic void setBaseClassifiers(Classifier[] classifiers)
classifiers
- an array of classifiers with all options set.public Classifier[] getBaseClassifiers()
public Classifier getBaseClassifier(int index)
index
- the index of the classifier to retrievepublic void setMetaClassifier(Classifier classifier)
classifier
- the classifier with all options set.public Classifier getMetaClassifier()
public void buildClassifier(Instances data) throws java.lang.Exception
buildClassifier
in class Classifier
data
- the training data to be used for generating the
boosted classifier.java.lang.Exception
- if the classifier could not be built successfullypublic double classifyInstance(Instance instance) throws java.lang.Exception
classifyInstance
in class Classifier
instance
- the instance to be classifiedjava.lang.Exception
- if instance could not be classified
successfullypublic java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] argv)
argv
- should contain the following arguments:
-t training file [-T test file] [-c class index]protected Instances metaFormat(Instances instances) throws java.lang.Exception
instances
- the level-0 formatprotected java.lang.String getBaseClassifierSpec(int index)
index
- the index of the classifier string to retrieve, starting from
0.protected java.lang.String getClassifierSpec(Classifier c)
c
- the classifierprotected Instance metaInstance(Instance instance) throws java.lang.Exception
instance
- the instance to be transformed
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |