Class PartitionedStacking

  • 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

    public class PartitionedStacking
    extends weka.classifiers.ParallelMultipleClassifiersCombiner
    Builds the base-classifiers on subsets of the data defined by ranges that correspond to the base-classifiers. The base-classifiers expect the class attribute to be the last attribute in the range of attributes that is defined for them.
    The predictions of the base-classifiers and the original class attribute are used to generated a new meta-dataset that is used as input for the meta-level classifier.

    Valid options are:

     -R <range>
      The attributes ranges to use for training the base-classifiers.
      Must be specified as often as there are base-classifiers.
      This is a comma separated list of attribute indices, with
      "first" and "last" valid values. Specify an inclusive
      range with "-". E.g: "first-3,5,6-10,last".
     -M <classifier specification>
      Full class name of the classifier to use for the meta-level,
      followed by scheme options.
      (default: "weka.classifiers.trees.M5P")
     -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")
     -D
      If set, classifier is run in debug mode and
      may output additional info to the console
    Version:
    $Revision$
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected weka.classifiers.Classifier m_MetaLevelClassifier
      the meta-level classifier.
      protected weka.core.Instances m_MetaLevelData
      the header for the meta-level data.
      protected weka.core.Range[] m_Ranges
      the attribute ranges for the base-classifiers.
      protected weka.filters.unsupervised.attribute.Remove[] m_Remove
      the filters for removing the unwanted attributes for the base classifiers.
      • Fields inherited from class weka.classifiers.ParallelMultipleClassifiersCombiner

        m_completed, m_executorPool, m_failed, m_numExecutionSlots
      • Fields inherited from class weka.classifiers.MultipleClassifiersCombiner

        m_Classifiers
      • Fields inherited from class weka.classifiers.AbstractClassifier

        BATCH_SIZE_DEFAULT, m_BatchSize, m_Debug, m_DoNotCheckCapabilities, m_numDecimalPlaces, NUM_DECIMAL_PLACES_DEFAULT
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void buildClassifier​(weka.core.Instances data)
      Builds the classifier.
      protected void buildClassifiers​(weka.core.Instances data)
      Does the actual construction of the base-classifiers.
      double classifyInstance​(weka.core.Instance instance)
      Classifies the given test instance.
      weka.core.Capabilities getCapabilities()
      Returns combined capabilities of the base classifiers, i.e., the capabilities all of them have in common.
      weka.classifiers.Classifier getMetaLevelClassifier()
      Returns the meta-level classifier.
      String[] getOptions()
      Gets the current settings of the Classifier.
      weka.core.Range[] getRanges()
      Returns the attribute ranges for the base-classifiers.
      String getRevision()
      Returns the revision string.
      String globalInfo()
      Returns a string describing this classifier.
      Enumeration listOptions()
      Returns an enumeration describing the available options.
      static void main​(String[] args)
      Main method for running this classifier.
      String metaLevelClassifierTipText()
      Returns the tip text for this property.
      String rangesTipText()
      Returns the tip text for this property.
      void setMetaLevelClassifier​(weka.classifiers.Classifier value)
      Sets the meta-level classifier.
      void setOptions​(String[] options)
      Parses a given list of options.
      void setRanges​(weka.core.Range[] value)
      Sets the attribute ranges for the base-classifiers.
      • Methods inherited from class weka.classifiers.ParallelMultipleClassifiersCombiner

        completedClassifier, getNumExecutionSlots, numExecutionSlotsTipText, setNumExecutionSlots, startExecutorPool
      • Methods inherited from class weka.classifiers.MultipleClassifiersCombiner

        classifiersTipText, getClassifier, getClassifiers, getClassifierSpec, postExecution, preExecution, setClassifiers
      • Methods inherited from class weka.classifiers.AbstractClassifier

        batchSizeTipText, debugTipText, distributionForInstance, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
    • Field Detail

      • m_MetaLevelClassifier

        protected weka.classifiers.Classifier m_MetaLevelClassifier
        the meta-level classifier.
      • m_Ranges

        protected weka.core.Range[] m_Ranges
        the attribute ranges for the base-classifiers.
      • m_Remove

        protected weka.filters.unsupervised.attribute.Remove[] m_Remove
        the filters for removing the unwanted attributes for the base classifiers.
      • m_MetaLevelData

        protected weka.core.Instances m_MetaLevelData
        the header for the meta-level data.
    • Constructor Detail

      • PartitionedStacking

        public PartitionedStacking()
    • Method Detail

      • globalInfo

        public String globalInfo()
        Returns a string describing this classifier.
        Returns:
        a description of the classifier suitable for displaying in the explorer/experimenter gui
      • listOptions

        public Enumeration listOptions()
        Returns an enumeration describing the available options.
        Specified by:
        listOptions in interface weka.core.OptionHandler
        Overrides:
        listOptions in class weka.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:

         -R <range>
          The attributes ranges to use for training the base-classifiers.
          Must be specified as often as there are base-classifiers.
          This is a comma separated list of attribute indices, with
          "first" and "last" valid values. Specify an inclusive
          range with "-". E.g: "first-3,5,6-10,last".
         -M <classifier specification>
          Full class name of the classifier to use for the meta-level,
          followed by scheme options.
          (default: "weka.classifiers.trees.M5P")
         -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")
         -D
          If set, classifier is run in debug mode and
          may output additional info to the console
        Specified by:
        setOptions in interface weka.core.OptionHandler
        Overrides:
        setOptions in class weka.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 interface weka.core.OptionHandler
        Overrides:
        getOptions in class weka.classifiers.ParallelMultipleClassifiersCombiner
        Returns:
        an array of strings suitable for passing to setOptions
      • setRanges

        public void setRanges​(weka.core.Range[] value)
        Sets the attribute ranges for the base-classifiers.
        Parameters:
        value - the ranges
      • getRanges

        public weka.core.Range[] getRanges()
        Returns the attribute ranges for the base-classifiers.
        Returns:
        the ranges
      • rangesTipText

        public String rangesTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the explorer/experimenter gui
      • setMetaLevelClassifier

        public void setMetaLevelClassifier​(weka.classifiers.Classifier value)
        Sets the meta-level classifier.
        Parameters:
        value - the meta-level classifier
      • getMetaLevelClassifier

        public weka.classifiers.Classifier getMetaLevelClassifier()
        Returns the meta-level classifier.
        Returns:
        the meta-level classifier
      • metaLevelClassifierTipText

        public String metaLevelClassifierTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the explorer/experimenter gui
      • 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 interface weka.core.CapabilitiesHandler
        Specified by:
        getCapabilities in interface weka.classifiers.Classifier
        Overrides:
        getCapabilities in class weka.classifiers.MultipleClassifiersCombiner
        Returns:
        the capabilities of the base classifiers
      • buildClassifiers

        protected void buildClassifiers​(weka.core.Instances data)
                                 throws Exception
        Does the actual construction of the base-classifiers.
        Overrides:
        buildClassifiers in class weka.classifiers.ParallelMultipleClassifiersCombiner
        Parameters:
        data - the data to use as basis for base-classifiers
        Throws:
        Exception - if something goes wrong during the training process
      • buildClassifier

        public void buildClassifier​(weka.core.Instances data)
                             throws Exception
        Builds the classifier.
        Specified by:
        buildClassifier in interface weka.classifiers.Classifier
        Overrides:
        buildClassifier in class weka.classifiers.ParallelMultipleClassifiersCombiner
        Parameters:
        data - the training data to be used for generating the classifier
        Throws:
        Exception - if the classifier could not be built successfully
      • classifyInstance

        public double classifyInstance​(weka.core.Instance instance)
                                throws Exception
        Classifies the given test instance. The instance has to belong to a dataset when it's being classified.
        Specified by:
        classifyInstance in interface weka.classifiers.Classifier
        Overrides:
        classifyInstance in class weka.classifiers.AbstractClassifier
        Parameters:
        instance - the instance to be classified
        Returns:
        the predicted most likely class for the instance or Utils.missingValue() if no prediction is made
        Throws:
        Exception - if an error occurred during the prediction
      • getRevision

        public String getRevision()
        Returns the revision string.
        Specified by:
        getRevision in interface weka.core.RevisionHandler
        Overrides:
        getRevision in class weka.classifiers.AbstractClassifier
        Returns:
        the revision
      • main

        public static void main​(String[] args)
        Main method for running this classifier.
        Parameters:
        args - the parameters, use -h to display them