Class AbstainingCascade

  • All Implemented Interfaces:
    Serializable, Cloneable, weka.classifiers.Classifier, weka.core.BatchPredictor, weka.core.CapabilitiesHandler, weka.core.CapabilitiesIgnorer, weka.core.CommandlineRunnable, ModelOutputHandler, weka.core.OptionHandler, weka.core.RevisionHandler

    public class AbstainingCascade
    extends weka.classifiers.MultipleClassifiersCombiner
    implements ModelOutputHandler
    The specified classifiers represent a cascade: if the first one abstains, the second is used (and so on), otherwise the prediction is returned.
    If all classifiers prior to the last one abstained then the prediction of the last one is returned.

    Valid options are:

     -suppress-model-output
      If enabled, suppresses any large model output.
     -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).
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean m_Built
      whether the models got built.
      protected boolean m_SuppressModelOutput
      whether to suppress the model output.
      static String SUPPRESS_MODEL_OUTPUT  
      • 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 Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void buildClassifier​(weka.core.Instances data)
      Builds the ensemble.
      double classifyInstance​(weka.core.Instance instance)
      Predicts the class label index for the given instance.
      double[] distributionForInstance​(weka.core.Instance instance)
      Predicts the class memberships for a given instance.
      String[] getOptions()
      Gets the current option settings for the OptionHandler.
      boolean getSuppressModelOutput()
      Returns whether to output the model with the toString() method or not.
      String globalInfo()
      Returns a string describing classifier
      Enumeration listOptions()
      Returns an enumeration describing the available options.
      void setOptions​(String[] options)
      Sets the OptionHandler's options using the given list.
      void setSuppressModelOutput​(boolean value)
      Sets whether to output the model with the toString() method or not.
      String suppressModelOutputTipText()
      Returns the tip text for this property.
      String toString()
      Outputs the ensemble model.
      • Methods inherited from class weka.classifiers.MultipleClassifiersCombiner

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

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

      • m_SuppressModelOutput

        protected boolean m_SuppressModelOutput
        whether to suppress the model output.
      • m_Built

        protected boolean m_Built
        whether the models got built.
    • Constructor Detail

      • AbstainingCascade

        public AbstainingCascade()
    • Method Detail

      • globalInfo

        public String globalInfo()
        Returns a string describing classifier
        Returns:
        a description suitable for displaying in the gui
      • setSuppressModelOutput

        public void setSuppressModelOutput​(boolean value)
        Sets whether to output the model with the toString() method or not.
        Specified by:
        setSuppressModelOutput in interface ModelOutputHandler
        Parameters:
        value - true if to suppress model output
      • getSuppressModelOutput

        public boolean getSuppressModelOutput()
        Returns whether to output the model with the toString() method or not.
        Specified by:
        getSuppressModelOutput in interface ModelOutputHandler
        Returns:
        the label index
      • suppressModelOutputTipText

        public String suppressModelOutputTipText()
        Returns the tip text for this property.
        Specified by:
        suppressModelOutputTipText in interface ModelOutputHandler
        Returns:
        tip text for this property suitable for displaying in the 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.MultipleClassifiersCombiner
        Returns:
        an enumeration of all the available options.
      • setOptions

        public void setOptions​(String[] options)
                        throws Exception
        Sets the OptionHandler's options using the given list. All options will be set (or reset) during this call (i.e. incremental setting of options is not possible).
        Specified by:
        setOptions in interface weka.core.OptionHandler
        Overrides:
        setOptions in class weka.classifiers.MultipleClassifiersCombiner
        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 option settings for the OptionHandler.
        Specified by:
        getOptions in interface weka.core.OptionHandler
        Overrides:
        getOptions in class weka.classifiers.MultipleClassifiersCombiner
        Returns:
        the list of current option settings as an array of strings
      • buildClassifier

        public void buildClassifier​(weka.core.Instances data)
                             throws Exception
        Builds the ensemble.
        Specified by:
        buildClassifier in interface weka.classifiers.Classifier
        Parameters:
        data - the training data
        Throws:
        Exception - if training fails
      • classifyInstance

        public double classifyInstance​(weka.core.Instance instance)
                                throws Exception
        Predicts the class label index for the given instance.
        Specified by:
        classifyInstance in interface weka.classifiers.Classifier
        Overrides:
        classifyInstance in class weka.classifiers.AbstractClassifier
        Parameters:
        instance - the instance to make the prediction for
        Returns:
        the class label index
        Throws:
        Exception - if prediction fails
      • distributionForInstance

        public double[] distributionForInstance​(weka.core.Instance instance)
                                         throws Exception
        Predicts the class memberships for a given instance. If an instance is unclassified, the returned array elements must be all zero. If the class is numeric, the array must consist of only one element, which contains the predicted value.
        Specified by:
        distributionForInstance in interface weka.classifiers.Classifier
        Overrides:
        distributionForInstance in class weka.classifiers.AbstractClassifier
        Parameters:
        instance - the instance to be classified
        Returns:
        an array containing the estimated membership probabilities of the test instance in each class or the numeric prediction
        Throws:
        Exception - if distribution could not be computed successfully
      • toString

        public String toString()
        Outputs the ensemble model.
        Overrides:
        toString in class Object
        Returns:
        the model