Class AbstainMinimumProbability

  • 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

    public class AbstainMinimumProbability
    extends weka.classifiers.SingleClassifierEnhancer
    implements AbstainingClassifier
    Abstains if the probability of the chosen class label is below the specified threshold.

    Valid options are:

     -W
      Full name of base classifier.
      (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).
     
     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).
     -min-probability <value>
      The minimum probability that the chosen label must meet.
      (default: 0.8)
    Version:
    $Revision$
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected double m_MinProbability
      the minimum probability that the classification must meet (0-1).
      protected int m_NumLabels
      the number of class labels.
      static String MIN_PROBABILITY  
      • Fields inherited from class weka.classifiers.SingleClassifierEnhancer

        m_Classifier
      • 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)
      Generates a classifier.
      boolean canAbstain()
      Whether abstaining is possible, e.g., used in meta-classifiers.
      double[] distributionForInstance​(weka.core.Instance instance)
      Returns the class distribution for an instance.
      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 base classifier.
      protected double getDefaultMinProbability()
      Returns the default minimum probability that the chosen class label must meet.
      double getMinProbability()
      Returns the minimum probability that the chosen class label must meet.
      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.
      String minProbabilityTipText()
      Returns the tip text for this property
      void setMinProbability​(double value)
      Sets the minimum probability that the chosen class label must meet.
      void setOptions​(String[] options)
      Sets the OptionHandler's options using the given list.
      String toString()
      Returns the model.
      • Methods inherited from class weka.classifiers.SingleClassifierEnhancer

        classifierTipText, defaultClassifierOptions, defaultClassifierString, getClassifier, getClassifierSpec, postExecution, preExecution, setClassifier
      • Methods inherited from class weka.classifiers.AbstractClassifier

        batchSizeTipText, classifyInstance, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, getRevision, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
      • Methods inherited from interface weka.classifiers.Classifier

        classifyInstance
    • Field Detail

      • m_MinProbability

        protected double m_MinProbability
        the minimum probability that the classification must meet (0-1).
      • m_NumLabels

        protected int m_NumLabels
        the number of class labels.
    • Constructor Detail

      • AbstainMinimumProbability

        public AbstainMinimumProbability()
    • Method Detail

      • globalInfo

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

        protected double getDefaultMinProbability()
        Returns the default minimum probability that the chosen class label must meet.
        Returns:
        value the default
      • setMinProbability

        public void setMinProbability​(double value)
        Sets the minimum probability that the chosen class label must meet.
        Parameters:
        value - the minimum probability
      • getMinProbability

        public double getMinProbability()
        Returns the minimum probability that the chosen class label must meet.
        Returns:
        value the minimum probability
      • minProbabilityTipText

        public String minProbabilityTipText()
        Returns the tip text for this property
        Returns:
        tip text for this property 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.SingleClassifierEnhancer
        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.SingleClassifierEnhancer
        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.SingleClassifierEnhancer
        Returns:
        the list of current option settings as an array of strings
      • getCapabilities

        public weka.core.Capabilities getCapabilities()
        Returns default capabilities of the base classifier.
        Specified by:
        getCapabilities in interface weka.core.CapabilitiesHandler
        Specified by:
        getCapabilities in interface weka.classifiers.Classifier
        Overrides:
        getCapabilities in class weka.classifiers.SingleClassifierEnhancer
        Returns:
        the capabilities of the base classifier
      • buildClassifier

        public void buildClassifier​(weka.core.Instances data)
                             throws Exception
        Generates a classifier. Must initialize all fields of the classifier that are not being set via options (ie. multiple calls of buildClassifier must always lead to the same result). Must not change the dataset in any way.
        Specified by:
        buildClassifier in interface weka.classifiers.Classifier
        Parameters:
        data - set of instances serving as training data
        Throws:
        Exception - if the classifier has not been generated successfully
      • 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
      • distributionForInstance

        public double[] distributionForInstance​(weka.core.Instance instance)
                                         throws Exception
        Returns the class distribution for an instance.
        Specified by:
        distributionForInstance in interface weka.classifiers.Classifier
        Overrides:
        distributionForInstance in class weka.classifiers.AbstractClassifier
        Parameters:
        instance - the instance to get the distribution for
        Returns:
        the distribution
        Throws:
        Exception - if classification fails
      • 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
        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
      • toString

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