public class Stacking extends RandomizableParallelMultipleClassifiersCombiner implements TechnicalInformationHandler
@article{Wolpert1992,
author = {David H. Wolpert},
journal = {Neural Networks},
pages = {241-259},
publisher = {Pergamon Press},
title = {Stacked generalization},
volume = {5},
year = {1992}
}
Valid options are:
-M <scheme specification> Full name of meta classifier, followed by options. (default: "weka.classifiers.rules.Zero")
-X <number of folds> Sets the number of cross-validation folds.
-S <num> Random number seed. (default 1)
-B <classifier specification> Full class name of classifier to include, followed by scheme options. May be specified multiple times. (default: "weka.classifiers.rules.ZeroR")
-D If set, classifier is run in debug mode and may output additional info to the console
| Modifier and Type | Field and Description |
|---|---|
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
|
m_Seedm_completed, m_executorPool, m_failed, m_numExecutionSlotsm_ClassifiersBATCH_SIZE_DEFAULT, m_BatchSize, m_Debug, m_DoNotCheckCapabilities, m_numDecimalPlaces, NUM_DECIMAL_PLACES_DEFAULT| Constructor and Description |
|---|
Stacking() |
| Modifier and Type | Method and Description |
|---|---|
void |
buildClassifier(Instances data)
Buildclassifier selects a classifier from the set of classifiers by minimising error on the
training data.
|
double[] |
distributionForInstance(Instance instance)
Returns class probabilities.
|
protected void |
generateMetaLevel(Instances newData,
java.util.Random random)
Generates the meta data
|
Capabilities |
getCapabilities()
Returns combined capabilities of the base classifiers, i.e., the capabilities all of them have in
common.
|
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.
|
java.lang.String |
getRevision()
Returns the revision string.
|
TechnicalInformation |
getTechnicalInformation()
Returns an instance of a TechnicalInformation object, containing detailed information about the
technical background of this class, e.g., paper reference or book this class is based on.
|
java.lang.String |
globalInfo()
Returns a string describing classifier
|
java.util.Enumeration<Option> |
listOptions()
Returns an enumeration describing the available options.
|
static void |
main(java.lang.String[] argv)
Main method for testing this class.
|
java.lang.String |
metaClassifierTipText()
Returns the tip text for this property
|
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.
|
protected java.lang.String |
metaOption()
String describing option for setting meta classifier
|
java.lang.String |
numFoldsTipText()
Returns the tip text for this property
|
void |
postExecution()
Perform any teardown stuff that might need to happen after execution.
|
void |
preExecution()
Perform any setup stuff that might need to happen before commandline
execution.
|
protected void |
processMetaOptions(java.lang.String[] options)
Process options setting meta classifier.
|
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.
|
java.lang.String |
toString()
Output a representation of this classifier
|
getSeed, seedTipText, setSeedbuildClassifiers, completedClassifier, getNumExecutionSlots, numExecutionSlotsTipText, setNumExecutionSlots, startExecutorPoolclassifiersTipText, getClassifier, getClassifiers, getClassifierSpec, setClassifiersbatchSizeTipText, classifyInstance, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlacesprotected Classifier m_MetaClassifier
protected Instances m_MetaFormat
protected Instances m_BaseFormat
protected int m_NumFolds
public java.lang.String globalInfo()
public TechnicalInformation getTechnicalInformation()
getTechnicalInformation in interface TechnicalInformationHandlerpublic java.util.Enumeration<Option> listOptions()
listOptions in interface OptionHandlerlistOptions in class RandomizableParallelMultipleClassifiersCombinerprotected java.lang.String metaOption()
public void setOptions(java.lang.String[] options)
throws java.lang.Exception
-M <scheme specification> Full name of meta classifier, followed by options. (default: "weka.classifiers.rules.Zero")
-X <number of folds> Sets the number of cross-validation folds.
-S <num> Random number seed. (default 1)
-B <classifier specification> Full class name of classifier to include, followed by scheme options. May be specified multiple times. (default: "weka.classifiers.rules.ZeroR")
-D If set, classifier is run in debug mode and may output additional info to the console
setOptions in interface OptionHandlersetOptions in class RandomizableParallelMultipleClassifiersCombineroptions - the list of options as an array of stringsjava.lang.Exception - if an option is not supportedprotected void processMetaOptions(java.lang.String[] options)
throws java.lang.Exception
options - the options to parsejava.lang.Exception - if the parsing failspublic java.lang.String[] getOptions()
getOptions in interface OptionHandlergetOptions in class RandomizableParallelMultipleClassifiersCombinerpublic java.lang.String numFoldsTipText()
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 java.lang.String metaClassifierTipText()
public void setMetaClassifier(Classifier classifier)
classifier - the classifier with all options set.public Classifier getMetaClassifier()
public Capabilities getCapabilities()
getCapabilities in interface ClassifiergetCapabilities in interface CapabilitiesHandlergetCapabilities in class MultipleClassifiersCombinerCapabilitiespublic void buildClassifier(Instances data) throws java.lang.Exception
buildClassifier in interface ClassifierbuildClassifier in class ParallelMultipleClassifiersCombinerdata - the training data to be used for generating the boosted classifier.java.lang.Exception - if the classifier could not be built successfullyprotected void generateMetaLevel(Instances newData, java.util.Random random) throws java.lang.Exception
newData - the data to work onrandom - the random number generator to use for cross-validationjava.lang.Exception - if generation failspublic double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance in interface ClassifierdistributionForInstance in class AbstractClassifierinstance - the instance to be classifiedjava.lang.Exception - if instance could not be classified successfullypublic java.lang.String toString()
toString in class java.lang.Objectprotected Instances metaFormat(Instances instances) throws java.lang.Exception
instances - the level-0 formatjava.lang.Exception - if the format generation failsprotected Instance metaInstance(Instance instance) throws java.lang.Exception
instance - the instance to be transformedjava.lang.Exception - if the instance generation failspublic void preExecution()
throws java.lang.Exception
AbstractClassifierpreExecution in interface CommandlineRunnablepreExecution in class MultipleClassifiersCombinerjava.lang.Exception - if a problem occurs during setuppublic void postExecution()
throws java.lang.Exception
AbstractClassifierpostExecution in interface CommandlineRunnablepostExecution in class MultipleClassifiersCombinerjava.lang.Exception - if a problem occurs during teardownpublic java.lang.String getRevision()
getRevision in interface RevisionHandlergetRevision in class AbstractClassifierpublic static void main(java.lang.String[] argv)
argv - should contain the following arguments: -t training file [-T test file] [-c class index]