Class AbstainAverage

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

    public class AbstainAverage
    extends weka.classifiers.MultipleClassifiersCombiner
    implements weka.core.WeightedInstancesHandler, AbstainingClassifier
    Average base classifiers, abstain if difference outside thresholds

    Valid options are:

    Version:
    $Revision: 12763 $
    Author:
    Dale
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean[] m_IsPercent  
      protected double m_MaxDifference  
      protected double[] m_MaxDifferences  
      protected String m_MaxDifferences_string  
      protected double[] m_Maxes  
      protected double[] m_Mins  
      • 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
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstainAverage()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void buildClassifier​(weka.core.Instances data)
      Buildclassifier builds all sub-classifiers
      boolean canAbstain()
      Whether abstaining is possible, e.g., used in meta-classifiers.
      protected boolean checkOK​(double avgPrediction, double difference)
      Check prediction difference against thresholds
      protected double classificationNumericAverage​(weka.core.Instance instance, boolean abstain)
      Do the classification.
      double classifyInstance​(weka.core.Instance instance)
      Classifies the given test instance.
      protected String diffToString()
      Convert thresholds from array to string
      double getAbstentionClassification​(weka.core.Instance inst)
      The prediction that made the classifier abstain.
      double[] getAbstentionDistribution​(weka.core.Instance inst)
      The class distribution that made the classifier abstain.
      weka.core.Capabilities getCapabilities()
      Returns default capabilities of the classifier.
      String getMaxDifference()
      gets number of samples
      String[] getOptions()
      Gets the current settings of Vote.
      String getRevision()
      Returns the revision string.
      String globalInfo()
      Returns a string describing classifier
      Enumeration listOptions()
      Returns an enumeration describing the available options.
      static void main​(String[] argv)
      Main method for testing this class.
      String maxDifferenceTipText()
      Returns the tip text for this property
      protected void parseString​(String input)
      Expect ; separated entries with min,max,difference e.g.
      void setMaxDifference​(String s)  
      void setOptions​(String[] options)
      Parses a given list of options.
      String toString()
      Output a representation of this classifier
      • 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
      • Methods inherited from interface weka.classifiers.Classifier

        distributionForInstance
    • Field Detail

      • m_MaxDifference

        protected double m_MaxDifference
      • m_MaxDifferences

        protected double[] m_MaxDifferences
      • m_Mins

        protected double[] m_Mins
      • m_Maxes

        protected double[] m_Maxes
      • m_IsPercent

        protected boolean[] m_IsPercent
      • m_MaxDifferences_string

        protected String m_MaxDifferences_string
    • Constructor Detail

      • AbstainAverage

        public AbstainAverage()
    • 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.MultipleClassifiersCombiner
        Returns:
        an enumeration of all the available options.
      • getOptions

        public String[] getOptions()
        Gets the current settings of Vote.
        Specified by:
        getOptions in interface weka.core.OptionHandler
        Overrides:
        getOptions in class weka.classifiers.MultipleClassifiersCombiner
        Returns:
        an array of strings suitable for passing to setOptions()
      • setOptions

        public void setOptions​(String[] options)
                        throws Exception
        Parses a given list of options.

        Valid options are:

         -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 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
      • getCapabilities

        public weka.core.Capabilities getCapabilities()
        Returns default capabilities of the classifier.
        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 this classifier
      • buildClassifier

        public void buildClassifier​(weka.core.Instances data)
                             throws Exception
        Buildclassifier builds all sub-classifiers
        Specified by:
        buildClassifier in interface weka.classifiers.Classifier
        Parameters:
        data - the training data to be used for generating the boosted 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.
        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 Instance.missingValue() if no prediction is made
        Throws:
        Exception - if an error occurred during the prediction
      • checkOK

        protected boolean checkOK​(double avgPrediction,
                                  double difference)
        Check prediction difference against thresholds
        Parameters:
        avgPrediction -
        difference -
        Returns:
      • parseString

        protected void parseString​(String input)
        Expect ; separated entries with min,max,difference e.g. 0-50,6;50-100,10%;100-200,20
        Parameters:
        input -
      • diffToString

        protected String diffToString()
        Convert thresholds from array to string
        Returns:
      • classificationNumericAverage

        protected double classificationNumericAverage​(weka.core.Instance instance,
                                                      boolean abstain)
                                               throws Exception
        Do the classification. Abstain (or not) depending on flag
        Parameters:
        instance -
        abstain -
        Returns:
        Throws:
        Exception
      • toString

        public String toString()
        Output a representation of this classifier
        Overrides:
        toString in class Object
        Returns:
        a string representation of the classifier
      • 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[] argv)
        Main method for testing this class.
        Parameters:
        argv - should contain the following arguments: -t training file [-T test file] [-c class index]
      • canAbstain

        public boolean canAbstain()
        Whether abstaining is possible, e.g., used in meta-classifiers.
        Specified by:
        canAbstain in interface AbstainingClassifier
        Returns:
        true if abstaining is possible
      • getAbstentionClassification

        public double getAbstentionClassification​(weka.core.Instance inst)
                                           throws Exception
        The prediction that made the classifier abstain.
        Specified by:
        getAbstentionClassification in interface AbstainingClassifier
        Parameters:
        inst - the instance to get the prediction for
        Returns:
        the prediction
        Throws:
        Exception - if fails to make prediction
      • getAbstentionDistribution

        public double[] getAbstentionDistribution​(weka.core.Instance inst)
                                           throws Exception
        Description copied from interface: AbstainingClassifier
        The class distribution that made the classifier abstain.
        Specified by:
        getAbstentionDistribution in interface AbstainingClassifier
        Parameters:
        inst - the instance to get the prediction for
        Returns:
        the class distribution
        Throws:
        Exception - if fails to make prediction
      • maxDifferenceTipText

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

        public String getMaxDifference()
        gets number of samples
        Returns:
        value
      • setMaxDifference

        public void setMaxDifference​(String s)