public class Stacking extends RandomizableMultipleClassifiersCombiner 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_Seed
m_Classifiers
m_Debug
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,
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.
|
String[] |
getOptions()
Gets the current settings of the Classifier.
|
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.
|
String |
globalInfo()
Returns a string describing classifier
|
Enumeration |
listOptions()
Returns an enumeration describing the available options.
|
static void |
main(String[] argv)
Main method for testing this class.
|
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 String |
metaOption()
String describing option for setting meta classifier
|
String |
numFoldsTipText()
Returns the tip text for this property
|
protected void |
processMetaOptions(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(String[] options)
Parses a given list of options.
|
String |
toString()
Output a representation of this classifier
|
getSeed, seedTipText, setSeed
classifiersTipText, getClassifier, getClassifiers, getClassifierSpec, setClassifiers
classifyInstance, debugTipText, forName, getDebug, makeCopies, makeCopy, runClassifier, setDebug
protected Classifier m_MetaClassifier
protected Instances m_MetaFormat
protected Instances m_BaseFormat
protected int m_NumFolds
public String globalInfo()
public TechnicalInformation getTechnicalInformation()
getTechnicalInformation
in interface TechnicalInformationHandler
public Enumeration listOptions()
listOptions
in interface OptionHandler
listOptions
in class RandomizableMultipleClassifiersCombiner
protected String metaOption()
public void setOptions(String[] options) throws 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 OptionHandler
setOptions
in class RandomizableMultipleClassifiersCombiner
options
- the list of options as an array of stringsException
- if an option is not supportedprotected void processMetaOptions(String[] options) throws Exception
options
- the options to parseException
- if the parsing failspublic String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class RandomizableMultipleClassifiersCombiner
public String numFoldsTipText()
public int getNumFolds()
public void setNumFolds(int numFolds) throws Exception
numFolds
- the number of folds for the cross-validationException
- if parameter illegalpublic String metaClassifierTipText()
public void setMetaClassifier(Classifier classifier)
classifier
- the classifier with all options set.public Classifier getMetaClassifier()
public Capabilities getCapabilities()
getCapabilities
in interface CapabilitiesHandler
getCapabilities
in class MultipleClassifiersCombiner
Capabilities
public void buildClassifier(Instances data) throws Exception
buildClassifier
in class Classifier
data
- the training data to be used for generating the
boosted classifier.Exception
- if the classifier could not be built successfullyprotected void generateMetaLevel(Instances newData, Random random) throws Exception
newData
- the data to work onrandom
- the random number generator to use for cross-validationException
- if generation failspublic double[] distributionForInstance(Instance instance) throws Exception
distributionForInstance
in class Classifier
instance
- the instance to be classifiedException
- if instance could not be classified
successfullypublic String toString()
protected Instances metaFormat(Instances instances) throws Exception
instances
- the level-0 formatException
- if the format generation failsprotected Instance metaInstance(Instance instance) throws Exception
instance
- the instance to be transformedException
- if the instance generation failspublic String getRevision()
getRevision
in interface RevisionHandler
getRevision
in class Classifier
public static void main(String[] argv)
argv
- should contain the following arguments:
-t training file [-T test file] [-c class index]Copyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.