Class Fallback

  • 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 Fallback
    extends weka.classifiers.AbstractClassifier
    In case the base classifier fails to make predictions, uses fallback one.
    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_ActualBase
      the actual base classifier.
      protected weka.classifiers.Classifier m_ActualFallback
      the actual fallback classifier.
      protected weka.classifiers.Classifier m_Base
      the base classifier.
      protected weka.classifiers.Classifier m_Fallback
      the fallback classifier.
      • Fields inherited from class weka.classifiers.AbstractClassifier

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

      Constructors 
      Constructor Description
      Fallback()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      String baseTipText()
      Returns the tip text for this property.
      void buildClassifier​(weka.core.Instances data)
      Generates a classifier.
      double classifyInstance​(weka.core.Instance instance)
      Classifies the given test instance.
      double[] distributionForInstance​(weka.core.Instance instance)
      Predicts the class memberships for a given instance.
      String fallbackTipText()
      Returns the tip text for this property.
      weka.classifiers.Classifier getBase()
      Returns the base classifier.
      weka.core.Capabilities getCapabilities()
      Returns the Capabilities of this classifier.
      protected weka.classifiers.Classifier getDefaultBase()
      Returns the default base classifier.
      protected weka.classifiers.Classifier getDefaultFallback()
      Returns the default fallback classifier.
      weka.classifiers.Classifier getFallback()
      Returns the fallback classifier.
      String[] getOptions()
      Gets the current option settings for the OptionHandler.
      String globalInfo()
      Returns a string describing classifier.
      Enumeration listOptions()
      Returns an enumeration describing the available options.
      void setBase​(weka.classifiers.Classifier value)
      Sets the base classifier.
      void setFallback​(weka.classifiers.Classifier value)
      Sets the fallback classifier.
      void setOptions​(String[] options)
      Sets the OptionHandler's options using the given list.
      String toString()
      Returns a description of the model.
      • Methods inherited from class weka.classifiers.AbstractClassifier

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

      • m_Base

        protected weka.classifiers.Classifier m_Base
        the base classifier.
      • m_ActualBase

        protected weka.classifiers.Classifier m_ActualBase
        the actual base classifier.
      • m_Fallback

        protected weka.classifiers.Classifier m_Fallback
        the fallback classifier.
      • m_ActualFallback

        protected weka.classifiers.Classifier m_ActualFallback
        the actual fallback classifier.
    • Constructor Detail

      • Fallback

        public Fallback()
    • Method Detail

      • globalInfo

        public String globalInfo()
        Returns a string describing classifier.
        Returns:
        a description 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.AbstractClassifier
        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.
        Specified by:
        setOptions in interface weka.core.OptionHandler
        Overrides:
        setOptions in class weka.classifiers.AbstractClassifier
        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.AbstractClassifier
        Returns:
        the list of current option settings as an array of strings
      • getDefaultBase

        protected weka.classifiers.Classifier getDefaultBase()
        Returns the default base classifier.
        Returns:
        the default
      • setBase

        public void setBase​(weka.classifiers.Classifier value)
        Sets the base classifier.
        Parameters:
        value - the base
      • getBase

        public weka.classifiers.Classifier getBase()
        Returns the base classifier.
        Returns:
        the base
      • baseTipText

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

        protected weka.classifiers.Classifier getDefaultFallback()
        Returns the default fallback classifier.
        Returns:
        the default
      • setFallback

        public void setFallback​(weka.classifiers.Classifier value)
        Sets the fallback classifier.
        Parameters:
        value - the fallback
      • getFallback

        public weka.classifiers.Classifier getFallback()
        Returns the fallback classifier.
        Returns:
        the fallback
      • fallbackTipText

        public String fallbackTipText()
        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 the Capabilities of this classifier.
        Specified by:
        getCapabilities in interface weka.core.CapabilitiesHandler
        Specified by:
        getCapabilities in interface weka.classifiers.Classifier
        Overrides:
        getCapabilities in class weka.classifiers.AbstractClassifier
        Returns:
        the capabilities of this object
        See Also:
        Capabilities
      • buildClassifier

        public void buildClassifier​(weka.core.Instances data)
                             throws Exception
        Generates a classifier.
        Parameters:
        data - set of instances serving as training data
        Throws:
        Exception - if the classifier has not been generated successfully
      • classifyInstance

        public double classifyInstance​(weka.core.Instance instance)
                                throws Exception
        Classifies the given test instance.
        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
      • 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()
        Returns a description of the model.
        Overrides:
        toString in class Object
        Returns:
        the description