Class MinMaxLimits

  • 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 MinMaxLimits
    extends weka.classifiers.SingleClassifierEnhancer
    implements weka.core.WeightedInstancesHandler, AbstainingClassifier
    Allows to influence the handling of lower/upper limits of the built classifier when making predictions.
    The following types of handling are available: AS_IS, MANUAL, CLASS_RANGE
    Details on the types:
    - AS_IS: prediction does not get changed
    - MANUAL: applies the manual limit, ie at most this limit is output
    - CLASS_RANGE: applies the percentage leeway to the class attribute range of the training set to determine the actual limit value.

    Valid options are:

     -min-handling <AS_IS|MANUAL|CLASS_RANGE>
      How the lower limit is handled.
      (default: AS_IS)
     -min-manual <num>
      The manual lower limit
      (default: 0.0)
     -min-class-percentage <num>
      The class range percentage leeway for the lower limit
      0-1 = 0-100%
      (default: 0.0)
     -max-handling <AS_IS|MANUAL|CLASS_RANGE>
      How the upper limit is handled.
      (default: AS_IS)
     -max-manual <num>
      The manual upper limit
      (default: 0.0)
     -max-class-percentage <num>
      The class range percentage leeway for the upper limit
      0-1 = 0-100%
      (default: 0.0)
     -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

      • DEFAULT_MIN_HANDLING

        public static final MinMaxLimits.LimitHandling DEFAULT_MIN_HANDLING
        the default handling of the lower limit.
      • DEFAULT_MIN_MANUAL

        public static final double DEFAULT_MIN_MANUAL
        the default manual limit of the lower limit.
        See Also:
        Constant Field Values
      • DEFAULT_MIN_CLASS_RANGE_PERCENTAGE

        public static final double DEFAULT_MIN_CLASS_RANGE_PERCENTAGE
        the default class range percentage for the lower limit.
        See Also:
        Constant Field Values
      • DEFAULT_MAX_HANDLING

        public static final MinMaxLimits.LimitHandling DEFAULT_MAX_HANDLING
        the default handling of the lower limit.
      • DEFAULT_MAX_MANUAL

        public static final double DEFAULT_MAX_MANUAL
        the default manual limit of the lower limit.
        See Also:
        Constant Field Values
      • DEFAULT_MAX_CLASS_RANGE_PERCENTAGE

        public static final double DEFAULT_MAX_CLASS_RANGE_PERCENTAGE
        the default class range percentage for the lower limit.
        See Also:
        Constant Field Values
      • m_MinManual

        protected double m_MinManual
        the manual limit for the lower limit.
      • m_MinClassRangePercentage

        protected double m_MinClassRangePercentage
        the percentage leeway for the class range of the lower limit (0-1 = 0-100%).
      • m_MinActual

        protected Double m_MinActual
        the actual limit to use for the lower limit.
      • m_MaxManual

        protected double m_MaxManual
        the manual limit for the upper limit.
      • m_MaxClassRangePercentage

        protected double m_MaxClassRangePercentage
        the percentage leeway for the class range of the upper limit (0-1 = 0-100%).
      • m_MaxActual

        protected Double m_MaxActual
        the actual limit to use for the upper limit.
      • m_CanAbstain

        protected boolean m_CanAbstain
        whether the base classifier can abstain.
    • Constructor Detail

      • MinMaxLimits

        public MinMaxLimits()
    • 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.SingleClassifierEnhancer
        Returns:
        an enumeration of all the available options.
      • setOptions

        public void setOptions​(String[] options)
                        throws Exception
        Parses a given list of options.
        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 settings of the classifier.
        Specified by:
        getOptions in interface weka.core.OptionHandler
        Overrides:
        getOptions in class weka.classifiers.SingleClassifierEnhancer
        Returns:
        an array of strings suitable for passing to setOptions
      • setMinHandling

        public void setMinHandling​(MinMaxLimits.LimitHandling value)
        Set how the lower limit is handled.
        Parameters:
        value - how the lower limit is handled
      • getMinHandling

        public MinMaxLimits.LimitHandling getMinHandling()
        Get how the lower limit is handled.
        Returns:
        how the lower limit is handled
      • minHandlingTipText

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

        public void setMinManual​(double value)
        Set the manual lower limit.
        Parameters:
        value - the manual lower limit
      • getMinManual

        public double getMinManual()
        Get the manual lower limit.
        Returns:
        the manual lower limit
      • minManualTipText

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

        public void setMinClassRangePercentage​(double value)
        Set the percentage of leeway to apply to the lower limit determined by the range of the class attribute in the training data.
        Parameters:
        value - the percentage (0-1 = 0-100%)
      • getMinClassRangePercentage

        public double getMinClassRangePercentage()
        Get the percentage of leeway to apply to the lower limit determined by the range of the class attribute in the training data.
        Returns:
        the percentage (0-1 = 0-100%)
      • minClassRangePercentageTipText

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

        public void setMaxHandling​(MinMaxLimits.LimitHandling value)
        Set how the upper limit is handled.
        Parameters:
        value - how the upper limit is handled
      • getMaxHandling

        public MinMaxLimits.LimitHandling getMaxHandling()
        Get how the upper limit is handled.
        Returns:
        how the upper limit is handled
      • maxHandlingTipText

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

        public void setMaxManual​(double value)
        Set the manual upper limit.
        Parameters:
        value - the manual upper limit
      • getMaxManual

        public double getMaxManual()
        Get the manual upper limit.
        Returns:
        the manual upper limit
      • maxManualTipText

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

        public void setMaxClassRangePercentage​(double value)
        Set the percentage of leeway to apply to the upper limit determaxed by the range of the class attribute in the training data.
        Parameters:
        value - the percentage (0-1 = 0-100%)
      • getMaxClassRangePercentage

        public double getMaxClassRangePercentage()
        Get the percentage of leeway to apply to the upper limit determaxed by the range of the class attribute in the training data.
        Returns:
        the percentage (0-1 = 0-100%)
      • maxClassRangePercentageTipText

        public String maxClassRangePercentageTipText()
        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 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
        Builds the classifier.
        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 inst)
                                throws Exception
        Returns the prediction.
        Specified by:
        classifyInstance in interface weka.classifiers.Classifier
        Overrides:
        classifyInstance in class weka.classifiers.AbstractClassifier
        Parameters:
        inst - the instance to predict
        Returns:
        the prediction
        Throws:
        Exception - if prediction fails
      • 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
        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 description of classifier.
        Overrides:
        toString in class Object
        Returns:
        the model
      • getRevision

        public String getRevision()
        Specified by:
        getRevision in interface weka.core.RevisionHandler
        Overrides:
        getRevision in class weka.classifiers.AbstractClassifier
      • main

        public static void main​(String[] args)
        Main method for running this class.
        Parameters:
        args - the options