Class Stacking

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, CapabilitiesHandler, OptionHandler, Randomizable, RevisionHandler, TechnicalInformationHandler
    Direct Known Subclasses:
    Grading, StackingC

    public class Stacking
    extends RandomizableMultipleClassifiersCombiner
    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
    Version:
    $Revision: 6996 $
    Author:
    Eibe Frank (eibe@cs.waikato.ac.nz)
    See Also:
    Serialized Form
    • Constructor Detail

      • Stacking

        public Stacking()
    • 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:
        getTechnicalInformation in interface TechnicalInformationHandler
        Returns:
        the technical information about this class
      • setOptions

        public void setOptions​(java.lang.String[] options)
                        throws java.lang.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")
         -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:
        setOptions in interface OptionHandler
        Overrides:
        setOptions in class RandomizableMultipleClassifiersCombiner
        Parameters:
        options - the list of options as an array of strings
        Throws:
        java.lang.Exception - if an option is not supported
      • 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.Exception
        Sets 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
      • 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:
        buildClassifier in class Classifier
        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.
        Overrides:
        distributionForInstance in class Classifier
        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:
        toString in class java.lang.Object
        Returns:
        a string representation of the classifier
      • 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]