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
BATCH_SIZE_DEFAULT, NUM_DECIMAL_PLACES_DEFAULT
Constructor and Description |
---|
Stacking() |
Modifier and Type | Method and Description |
---|---|
boolean |
baseClassifiersImplementMoreEfficientBatchPrediction()
Returns true if any of the base classifiers are able to generate batch predictions
efficiently and all of them implement BatchPredictor.
|
void |
buildClassifier(Instances data)
Builds a classifier using stacking.
|
double[] |
distributionForInstance(Instance instance)
Returns estimated class probabilities for the given instance if the class is nominal and a
one-element array containing the numeric prediction if the class is numeric.
|
double[][] |
distributionsForInstances(Instances instances)
Returns class probabilities for all given instances if the class is nominal or corresponding predicted
numeric values if the class is numeric.
|
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
|
boolean |
implementsMoreEfficientBatchPrediction()
Returns true if the meta classifier or any of the base classifiers are able to generate batch predictions
efficiently and all of them implement BatchPredictor.
|
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
|
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.
|
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, setSeed
getNumExecutionSlots, numExecutionSlotsTipText, setNumExecutionSlots
classifiersTipText, getClassifier, getClassifiers, setClassifiers
batchSizeTipText, classifyInstance, debugTipText, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, makeCopies, makeCopy, numDecimalPlacesTipText, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
makeCopy
public java.lang.String globalInfo()
public TechnicalInformation getTechnicalInformation()
getTechnicalInformation
in interface TechnicalInformationHandler
public java.util.Enumeration<Option> listOptions()
listOptions
in interface OptionHandler
listOptions
in class RandomizableParallelMultipleClassifiersCombiner
public void setOptions(java.lang.String[] options) throws java.lang.Exception
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
setOptions
in interface OptionHandler
setOptions
in class RandomizableParallelMultipleClassifiersCombiner
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
getOptions
in class RandomizableParallelMultipleClassifiersCombiner
public 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 Classifier
getCapabilities
in interface CapabilitiesHandler
getCapabilities
in class MultipleClassifiersCombiner
Capabilities
public boolean implementsMoreEfficientBatchPrediction()
implementsMoreEfficientBatchPrediction
in interface BatchPredictor
implementsMoreEfficientBatchPrediction
in class AbstractClassifier
public boolean baseClassifiersImplementMoreEfficientBatchPrediction()
public void buildClassifier(Instances data) throws java.lang.Exception
buildClassifier
in interface Classifier
buildClassifier
in class ParallelMultipleClassifiersCombiner
data
- the training data to be used for generating the stacked classifier.java.lang.Exception
- if the classifier could not be built successfullypublic double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance
in interface Classifier
distributionForInstance
in class AbstractClassifier
instance
- the instance to be classifiedjava.lang.Exception
- if instance could not be classified successfullypublic double[][] distributionsForInstances(Instances instances) throws java.lang.Exception
distributionsForInstances
in interface BatchPredictor
distributionsForInstances
in class AbstractClassifier
instances
- the instance sto be classifiedjava.lang.Exception
- if instances could not be classified successfullypublic java.lang.String toString()
toString
in class java.lang.Object
public void preExecution() throws java.lang.Exception
AbstractClassifier
preExecution
in interface CommandlineRunnable
preExecution
in class MultipleClassifiersCombiner
java.lang.Exception
- if a problem occurs during setuppublic void postExecution() throws java.lang.Exception
AbstractClassifier
postExecution
in interface CommandlineRunnable
postExecution
in class MultipleClassifiersCombiner
java.lang.Exception
- if a problem occurs during teardownpublic java.lang.String getRevision()
getRevision
in interface RevisionHandler
getRevision
in class AbstractClassifier
public static void main(java.lang.String[] argv)
argv
- should contain the following arguments:
-t training file [-T test file] [-c class index]