weka.classifiers.meta
Class Stacking
- java.lang.Object
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, Classifier, BatchPredictor, CapabilitiesHandler, CapabilitiesIgnorer, CommandlineRunnable, OptionHandler, Randomizable, RevisionHandler, TechnicalInformationHandler
public class Stacking extends RandomizableParallelMultipleClassifiersCombiner implements TechnicalInformationHandler
Combines several classifiers using the stacking method. Can do classification or regression.
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")
-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
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class weka.classifiers.AbstractClassifier
BATCH_SIZE_DEFAULT, NUM_DECIMAL_PLACES_DEFAULT
-
-
Constructor Summary
Constructors Constructor and Description Stacking()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidbuildClassifier(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.CapabilitiesgetCapabilities()Returns combined capabilities of the base classifiers, i.e., the capabilities all of them have in common.ClassifiergetMetaClassifier()Gets the meta classifier.intgetNumFolds()Gets the number of folds for the cross-validation.java.lang.String[]getOptions()Gets the current settings of the Classifier.java.lang.StringgetRevision()Returns the revision string.TechnicalInformationgetTechnicalInformation()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.StringglobalInfo()Returns a string describing classifierjava.util.Enumeration<Option>listOptions()Returns an enumeration describing the available options.static voidmain(java.lang.String[] argv)Main method for testing this class.java.lang.StringmetaClassifierTipText()Returns the tip text for this propertyjava.lang.StringnumFoldsTipText()Returns the tip text for this propertyvoidpostExecution()Perform any teardown stuff that might need to happen after execution.voidpreExecution()Perform any setup stuff that might need to happen before commandline execution.voidsetMetaClassifier(Classifier classifier)Adds meta classifiervoidsetNumFolds(int numFolds)Sets the number of folds for the cross-validation.voidsetOptions(java.lang.String[] options)Parses a given list of options.java.lang.StringtoString()Output a representation of this classifier-
Methods inherited from class weka.classifiers.RandomizableParallelMultipleClassifiersCombiner
getSeed, seedTipText, setSeed
-
Methods inherited from class weka.classifiers.ParallelMultipleClassifiersCombiner
getNumExecutionSlots, numExecutionSlotsTipText, setNumExecutionSlots
-
Methods inherited from class weka.classifiers.MultipleClassifiersCombiner
classifiersTipText, getClassifier, getClassifiers, 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
-
-
-
-
Method Detail
-
globalInfo
public java.lang.String globalInfo()
Returns a string describing classifier- Returns:
- a description suitable for displaying in the explorer/experimenter gui
-
getTechnicalInformation
public 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:
getTechnicalInformationin interfaceTechnicalInformationHandler- Returns:
- the technical information about this class
-
listOptions
public java.util.Enumeration<Option> listOptions()
Returns an enumeration describing the available options.- Specified by:
listOptionsin interfaceOptionHandler- Overrides:
listOptionsin classRandomizableParallelMultipleClassifiersCombiner- Returns:
- an enumeration of all the available options.
-
setOptions
public void setOptions(java.lang.String[] options) throws java.lang.ExceptionParses a given list of options. 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
- Specified by:
setOptionsin interfaceOptionHandler- Overrides:
setOptionsin classRandomizableParallelMultipleClassifiersCombiner- Parameters:
options- the list of options as an array of strings- Throws:
java.lang.Exception- if an option is not supported
-
getOptions
public java.lang.String[] getOptions()
Gets the current settings of the Classifier.- Specified by:
getOptionsin interfaceOptionHandler- Overrides:
getOptionsin classRandomizableParallelMultipleClassifiersCombiner- Returns:
- an array of strings suitable for passing to setOptions
-
numFoldsTipText
public java.lang.String numFoldsTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getNumFolds
public int getNumFolds()
Gets the number of folds for the cross-validation.- Returns:
- the number of folds for the cross-validation
-
setNumFolds
public void setNumFolds(int numFolds) throws java.lang.ExceptionSets the number of folds for the cross-validation.- Parameters:
numFolds- the number of folds for the cross-validation- Throws:
java.lang.Exception- if parameter illegal
-
metaClassifierTipText
public java.lang.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(Classifier classifier)
Adds meta classifier- Parameters:
classifier- the classifier with all options set.
-
getMetaClassifier
public Classifier getMetaClassifier()
Gets the meta classifier.- Returns:
- the meta classifier
-
getCapabilities
public Capabilities getCapabilities()
Returns combined capabilities of the base classifiers, i.e., the capabilities all of them have in common.- Specified by:
getCapabilitiesin interfaceClassifier- Specified by:
getCapabilitiesin interfaceCapabilitiesHandler- Overrides:
getCapabilitiesin classMultipleClassifiersCombiner- Returns:
- the capabilities of the base classifiers
- See Also:
Capabilities
-
buildClassifier
public void buildClassifier(Instances data) throws java.lang.Exception
Buildclassifier selects a classifier from the set of classifiers by minimising error on the training data.- Specified by:
buildClassifierin interfaceClassifier- Overrides:
buildClassifierin classParallelMultipleClassifiersCombiner- Parameters:
data- the training data to be used for generating the boosted classifier.- Throws:
java.lang.Exception- if the classifier could not be built successfully
-
distributionForInstance
public double[] distributionForInstance(Instance instance) throws java.lang.Exception
Returns class probabilities.- Specified by:
distributionForInstancein interfaceClassifier- Overrides:
distributionForInstancein classAbstractClassifier- Parameters:
instance- the instance to be classified- Returns:
- the distribution
- Throws:
java.lang.Exception- if instance could not be classified successfully
-
toString
public java.lang.String toString()
Output a representation of this classifier- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation of the classifier
-
preExecution
public void preExecution() throws java.lang.ExceptionDescription copied from class:AbstractClassifierPerform any setup stuff that might need to happen before commandline execution. Subclasses should override if they need to do something here- Specified by:
preExecutionin interfaceCommandlineRunnable- Overrides:
preExecutionin classMultipleClassifiersCombiner- Throws:
java.lang.Exception- if a problem occurs during setup
-
postExecution
public void postExecution() throws java.lang.ExceptionDescription copied from class:AbstractClassifierPerform any teardown stuff that might need to happen after execution. Subclasses should override if they need to do something here- Specified by:
postExecutionin interfaceCommandlineRunnable- Overrides:
postExecutionin classMultipleClassifiersCombiner- Throws:
java.lang.Exception- if a problem occurs during teardown
-
getRevision
public java.lang.String getRevision()
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Overrides:
getRevisionin classAbstractClassifier- Returns:
- the revision
-
main
public static void main(java.lang.String[] argv)
Main method for testing this class.- Parameters:
argv- should contain the following arguments: -t training file [-T test file] [-c class index]
-
-
DataMelt 3.0 © DataMelt by jWork.ORG