Class ThresholdedBinaryClassification

  • 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 ThresholdedBinaryClassification
    extends weka.classifiers.SingleClassifierEnhancer
    implements ModelOutputHandler
    Meta classifier for binary classification problems that allows to specify a minimum probability threshold for one of the labels. If this label achieves at least this probability then this label gets chosen, otherwise the other one.

    Valid options are:

     -label <value>
      The index of the label to check.
      (default: first)
     -min-probability <value>
      The minimum probability for the label (0-1).
      (default: 0.5)
     -suppress-model-output
      If enabled, suppresses any large model output.
     -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).
    Version:
    $Revision$
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_ActualLabel

        protected int m_ActualLabel
        the index of the label to check.
      • m_OtherLabel

        protected int m_OtherLabel
        the index of the other label.
      • m_MinProbability

        protected double m_MinProbability
        the minimum probability for the label.
      • m_SuppressModelOutput

        protected boolean m_SuppressModelOutput
        whether to suppress the model output.
    • Constructor Detail

      • ThresholdedBinaryClassification

        public ThresholdedBinaryClassification()
    • Method Detail

      • globalInfo

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

        protected WekaLabelIndex getDefaultLabel()
        Returns the default label index.
        Returns:
        the default
      • setLabel

        public void setLabel​(WekaLabelIndex value)
        Sets the label index to use.
        Parameters:
        value - the label index
      • getLabel

        public WekaLabelIndex getLabel()
        Returns the label index.
        Returns:
        the label index
      • labelTipText

        public String labelTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the gui
      • getDefaultMinProbability

        protected double getDefaultMinProbability()
        Returns the default minimum probability.
        Returns:
        the default
      • setMinProbability

        public void setMinProbability​(double value)
        Sets the minimum probability for the selected label.
        Parameters:
        value - the probability
      • getMinProbability

        public double getMinProbability()
        Returns the minimum probability for the selected label.
        Returns:
        the probability
      • minProbabilityTipText

        public String minProbabilityTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property 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.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 the ensemble's capabilities.
        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
      • buildClassifier

        public void buildClassifier​(weka.core.Instances data)
                             throws Exception
        Builds the classifier with the training data.
        Specified by:
        buildClassifier in interface weka.classifiers.Classifier
        Parameters:
        data - the training data
        Throws:
        Exception
      • distributionForInstance

        public double[] distributionForInstance​(weka.core.Instance instance)
                                         throws Exception
        Returns the class distribution for the instance.
        Specified by:
        distributionForInstance in interface weka.classifiers.Classifier
        Overrides:
        distributionForInstance in class weka.classifiers.AbstractClassifier
        Parameters:
        instance - the instance to make the prediction for
        Returns:
        the class distribution
        Throws:
        Exception - if classification fails
      • toString

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