Package weka.classifiers.meta
Class GroupedStacking
- java.lang.Object
-
- weka.classifiers.AbstractClassifier
-
- weka.classifiers.MultipleClassifiersCombiner
-
- weka.classifiers.ParallelMultipleClassifiersCombiner
-
- weka.classifiers.meta.GroupedStacking
-
- All Implemented Interfaces:
Serializable
,Cloneable
,weka.classifiers.Classifier
,weka.core.BatchPredictor
,weka.core.CapabilitiesHandler
,weka.core.CapabilitiesIgnorer
,weka.core.CommandlineRunnable
,weka.core.OptionHandler
,weka.core.RevisionHandler
,weka.core.TechnicalInformationHandler
public class GroupedStacking extends weka.classifiers.ParallelMultipleClassifiersCombiner implements weka.core.TechnicalInformationHandler
Combines several classifiers using the stacking method. Can do classification or regression.
Uses the specified fold generator for generating the fold pairs for the meta-level.
For more information, see
David H. Wolpert (1992). Stacked generalization. Neural Networks. 5:241-259.
BibTeX:@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")
-generator <classname and options> Sets the cross-validation fold generator to use. (default: weka.classifiers.DefaultCrossValidationFoldGenerator)
-num-slots <num> Number of execution slots. (default 1 - i.e. no parallelism)
-B <classifier specification> Full class name of classifier to include, followed by scheme options. May be specified multiple times. (default: "weka.classifiers.rules.ZeroR")
-output-debug-info If set, classifier is run in debug mode and may output additional info to the console
-do-not-check-capabilities If set, classifier capabilities are not checked before classifier is built (use with caution).
-num-decimal-places The number of decimal places for the output of numbers in the model (default 2).
-batch-size The desired batch size for batch prediction (default 100).
Options specific to classifier weka.classifiers.rules.ZeroR:
-output-debug-info If set, classifier is run in debug mode and may output additional info to the console
-do-not-check-capabilities If set, classifier capabilities are not checked before classifier is built (use with caution).
-num-decimal-places The number of decimal places for the output of numbers in the model (default 2).
-batch-size The desired batch size for batch prediction (default 100).
Options specific to meta classifier weka.classifiers.rules.ZeroR:
-output-debug-info If set, classifier is run in debug mode and may output additional info to the console
-do-not-check-capabilities If set, classifier capabilities are not checked before classifier is built (use with caution).
-num-decimal-places The number of decimal places for the output of numbers in the model (default 2).
-batch-size The desired batch size for batch prediction (default 100).
- Author:
- Eibe Frank ([email protected])
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected CrossValidationFoldGenerator
m_ActualGenerator
the actual fold generator in use.protected weka.core.Instances
m_BaseFormat
Format for base dataprotected CrossValidationFoldGenerator
m_Generator
the fold generator.protected weka.classifiers.Classifier
m_MetaClassifier
The meta classifierprotected weka.core.Instances
m_MetaFormat
Format for meta data
-
Constructor Summary
Constructors Constructor Description GroupedStacking()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
buildClassifier(weka.core.Instances data)
Buildclassifier selects a classifier from the set of classifiers by minimising error on the training data.double[]
distributionForInstance(weka.core.Instance instance)
Returns class probabilities.protected void
generateMetaLevel(weka.core.Instances newData)
Generates the meta dataString
generatorTipText()
Returns the tip text for this propertyweka.core.Capabilities
getCapabilities()
Returns combined capabilities of the base classifiers, i.e., the capabilities all of them have in common.CrossValidationFoldGenerator
getGenerator()
Gets the cross-validation fold generator to use.weka.classifiers.Classifier
getMetaClassifier()
Gets the meta classifier.String[]
getOptions()
Gets the current settings of the Classifier.String
getRevision()
Returns the revision string.weka.core.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 classifierEnumeration<weka.core.Option>
listOptions()
Returns an enumeration describing the available options.static void
main(String[] args)
Main method for testing this class.String
metaClassifierTipText()
Returns the tip text for this propertyprotected weka.core.Instances
metaFormat(weka.core.Instances instances)
Makes the format for the level-1 data.protected weka.core.Instance
metaInstance(weka.core.Instance instance)
Makes a level-1 instance from the given instance.void
postExecution()
void
preExecution()
void
setGenerator(CrossValidationFoldGenerator value)
Sets the cross-validation fold generator to use.void
setMetaClassifier(weka.classifiers.Classifier classifier)
Adds meta classifiervoid
setOptions(String[] options)
Parses a given list of options.String
toString()
Output a representation of this classifier-
Methods inherited from class weka.classifiers.ParallelMultipleClassifiersCombiner
buildClassifiers, completedClassifier, getNumExecutionSlots, numExecutionSlotsTipText, setNumExecutionSlots, startExecutorPool
-
Methods inherited from class weka.classifiers.MultipleClassifiersCombiner
classifiersTipText, getClassifier, getClassifiers, getClassifierSpec, setClassifiers
-
Methods inherited from class weka.classifiers.AbstractClassifier
batchSizeTipText, classifyInstance, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
-
-
-
-
Field Detail
-
m_MetaClassifier
protected weka.classifiers.Classifier m_MetaClassifier
The meta classifier
-
m_MetaFormat
protected weka.core.Instances m_MetaFormat
Format for meta data
-
m_BaseFormat
protected weka.core.Instances m_BaseFormat
Format for base data
-
m_Generator
protected CrossValidationFoldGenerator m_Generator
the fold generator.
-
m_ActualGenerator
protected CrossValidationFoldGenerator m_ActualGenerator
the actual fold generator in use.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing classifier- Returns:
- a description suitable for displaying in the explorer/experimenter gui
-
getTechnicalInformation
public weka.core.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.- Specified by:
getTechnicalInformation
in interfaceweka.core.TechnicalInformationHandler
- Returns:
- the technical information about this class
-
listOptions
public Enumeration<weka.core.Option> listOptions()
Returns an enumeration describing the available options.- Specified by:
listOptions
in interfaceweka.core.OptionHandler
- Overrides:
listOptions
in classweka.classifiers.ParallelMultipleClassifiersCombiner
- Returns:
- an enumeration of all the available options.
-
setOptions
public void setOptions(String[] options) throws Exception
Parses a given list of options. Valid options are:-M <scheme specification> Full name of meta classifier, followed by options. (default: "weka.classifiers.rules.Zero")
-generator <classname and options> Sets the cross-validation fold generator to use. (default: weka.classifiers.DefaultCrossValidationFoldGenerator)
-num-slots <num> Number of execution slots. (default 1 - i.e. no parallelism)
-B <classifier specification> Full class name of classifier to include, followed by scheme options. May be specified multiple times. (default: "weka.classifiers.rules.ZeroR")
-output-debug-info If set, classifier is run in debug mode and may output additional info to the console
-do-not-check-capabilities If set, classifier capabilities are not checked before classifier is built (use with caution).
-num-decimal-places The number of decimal places for the output of numbers in the model (default 2).
-batch-size The desired batch size for batch prediction (default 100).
Options specific to classifier weka.classifiers.rules.ZeroR:
-output-debug-info If set, classifier is run in debug mode and may output additional info to the console
-do-not-check-capabilities If set, classifier capabilities are not checked before classifier is built (use with caution).
-num-decimal-places The number of decimal places for the output of numbers in the model (default 2).
-batch-size The desired batch size for batch prediction (default 100).
Options specific to meta classifier weka.classifiers.rules.ZeroR:
-output-debug-info If set, classifier is run in debug mode and may output additional info to the console
-do-not-check-capabilities If set, classifier capabilities are not checked before classifier is built (use with caution).
-num-decimal-places The number of decimal places for the output of numbers in the model (default 2).
-batch-size The desired batch size for batch prediction (default 100).
- Specified by:
setOptions
in interfaceweka.core.OptionHandler
- Overrides:
setOptions
in classweka.classifiers.ParallelMultipleClassifiersCombiner
- Parameters:
options
- the list of options as an array of strings- Throws:
Exception
- if an option is not supported
-
getOptions
public String[] getOptions()
Gets the current settings of the Classifier.- Specified by:
getOptions
in interfaceweka.core.OptionHandler
- Overrides:
getOptions
in classweka.classifiers.ParallelMultipleClassifiersCombiner
- Returns:
- an array of strings suitable for passing to setOptions
-
generatorTipText
public String generatorTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getGenerator
public CrossValidationFoldGenerator getGenerator()
Gets the cross-validation fold generator to use.- Returns:
- the generator
-
setGenerator
public void setGenerator(CrossValidationFoldGenerator value)
Sets the cross-validation fold generator to use.- Parameters:
value
- the generator
-
metaClassifierTipText
public String metaClassifierTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setMetaClassifier
public void setMetaClassifier(weka.classifiers.Classifier classifier)
Adds meta classifier- Parameters:
classifier
- the classifier with all options set.
-
getMetaClassifier
public weka.classifiers.Classifier getMetaClassifier()
Gets the meta classifier.- Returns:
- the meta classifier
-
getCapabilities
public weka.core.Capabilities getCapabilities()
Returns combined capabilities of the base classifiers, i.e., the capabilities all of them have in common.- Specified by:
getCapabilities
in interfaceweka.core.CapabilitiesHandler
- Specified by:
getCapabilities
in interfaceweka.classifiers.Classifier
- Overrides:
getCapabilities
in classweka.classifiers.MultipleClassifiersCombiner
- Returns:
- the capabilities of the base classifiers
-
buildClassifier
public void buildClassifier(weka.core.Instances data) throws Exception
Buildclassifier selects a classifier from the set of classifiers by minimising error on the training data.- Specified by:
buildClassifier
in interfaceweka.classifiers.Classifier
- Overrides:
buildClassifier
in classweka.classifiers.ParallelMultipleClassifiersCombiner
- Parameters:
data
- the training data to be used for generating the boosted classifier.- Throws:
Exception
- if the classifier could not be built successfully
-
generateMetaLevel
protected void generateMetaLevel(weka.core.Instances newData) throws Exception
Generates the meta data- Parameters:
newData
- the data to work on- Throws:
Exception
- if generation fails
-
distributionForInstance
public double[] distributionForInstance(weka.core.Instance instance) throws Exception
Returns class probabilities.- Specified by:
distributionForInstance
in interfaceweka.classifiers.Classifier
- Overrides:
distributionForInstance
in classweka.classifiers.AbstractClassifier
- Parameters:
instance
- the instance to be classified- Returns:
- the distribution
- Throws:
Exception
- if instance could not be classified successfully
-
toString
public String toString()
Output a representation of this classifier
-
metaFormat
protected weka.core.Instances metaFormat(weka.core.Instances instances) throws Exception
Makes the format for the level-1 data.- Parameters:
instances
- the level-0 format- Returns:
- the format for the meta data
- Throws:
Exception
- if the format generation fails
-
metaInstance
protected weka.core.Instance metaInstance(weka.core.Instance instance) throws Exception
Makes a level-1 instance from the given instance.- Parameters:
instance
- the instance to be transformed- Returns:
- the level-1 instance
- Throws:
Exception
- if the instance generation fails
-
preExecution
public void preExecution() throws Exception
- Specified by:
preExecution
in interfaceweka.core.CommandlineRunnable
- Overrides:
preExecution
in classweka.classifiers.MultipleClassifiersCombiner
- Throws:
Exception
-
postExecution
public void postExecution() throws Exception
- Specified by:
postExecution
in interfaceweka.core.CommandlineRunnable
- Overrides:
postExecution
in classweka.classifiers.MultipleClassifiersCombiner
- Throws:
Exception
-
getRevision
public String getRevision()
Returns the revision string.- Specified by:
getRevision
in interfaceweka.core.RevisionHandler
- Overrides:
getRevision
in classweka.classifiers.AbstractClassifier
- Returns:
- the revision
-
main
public static void main(String[] args)
Main method for testing this class.- Parameters:
args
- should contain the following arguments: -t training file [-T test file] [-c class index]
-
-