Class MathExprClassRegressor

  • 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 MathExprClassRegressor
    extends weka.classifiers.SingleClassifierEnhancer
    Applies the 'transform' expression to the class attribute in the data for training the based classifier and the 'inverse' expression at prediction time to convert the predicted class value back into input space.

    Valid options are:

     -transform <expression>
      The expression to transform the class value.
      (default: log(1+X))
     -inverse <expression>
      The expression to inverse transform the predicted class value.
      (default: exp(X)-1)
     -W <classifier name>
      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).
     -num-decimal-places
      The number of decimal places for the output of numbers in the model (default 2).
     -batch-size
      The desired batch size for batch prediction  (default 100).
     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).
     -num-decimal-places
      The number of decimal places for the output of numbers in the model (default 2).
     -batch-size
      The desired batch size for batch prediction  (default 100).
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String INVERSE  
      protected MathematicalExpressionText m_Inverse
      the expression to inverse transform the class value.
      protected MathematicalExpressionText m_Transform
      the expression to transform the class value.
      static String TRANSFORM  
      • 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 Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void buildClassifier​(weka.core.Instances data)
      Builds the classifier.
      double classifyInstance​(weka.core.Instance inst)
      Returns the prediction.
      MathematicalExpressionText getInverse()
      Get the mathematical expression for inverse transforming the class value for the base classifier.
      String[] getOptions()
      Gets the current settings of the classifier.
      String getRevision()
      Returns the revision string.
      MathematicalExpressionText getTransform()
      Get the mathematical expression for transforming the class value for the base classifier.
      String globalInfo()
      Returns a string describing classifier.
      protected double inverse​(double x)
      Inverse transforms the value.
      String inverseTipText()
      Returns the tip text for this property.
      Enumeration listOptions()
      Returns an enumeration describing the available options.
      static void main​(String[] args)
      Main method for running this class.
      void setInverse​(MathematicalExpressionText value)
      Set the mathematical expression for inverse transforming the class value for the base classifier.
      void setOptions​(String[] options)
      Parses a given list of options.
      void setTransform​(MathematicalExpressionText value)
      Set the mathematical expression for transforming the class value for the base classifier.
      String toString()
      Returns description of classifier.
      protected double transform​(double x)
      Transforms the value.
      protected weka.core.Instance transform​(weka.core.Instance inst)
      Transforms the instance.
      String transformTipText()
      Returns the tip text for this property.
      • Methods inherited from class weka.classifiers.SingleClassifierEnhancer

        classifierTipText, defaultClassifierOptions, defaultClassifierString, getCapabilities, getClassifier, getClassifierSpec, postExecution, preExecution, setClassifier
      • 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
    • Constructor Detail

      • MathExprClassRegressor

        public MathExprClassRegressor()
    • 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
      • setTransform

        public void setTransform​(MathematicalExpressionText value)
        Set the mathematical expression for transforming the class value for the base classifier.
        Parameters:
        value - the expression
      • getTransform

        public MathematicalExpressionText getTransform()
        Get the mathematical expression for transforming the class value for the base classifier.
        Returns:
        the expression
      • transformTipText

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

        public void setInverse​(MathematicalExpressionText value)
        Set the mathematical expression for inverse transforming the class value for the base classifier.
        Parameters:
        value - the expression
      • getInverse

        public MathematicalExpressionText getInverse()
        Get the mathematical expression for inverse transforming the class value for the base classifier.
        Returns:
        the expression
      • inverseTipText

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

        protected weka.core.Instance transform​(weka.core.Instance inst)
                                        throws Exception
        Transforms the instance.
        Parameters:
        inst - the instance to transform
        Returns:
        the transformed instance
        Throws:
        Exception - if evaluation of formula fails
      • transform

        protected double transform​(double x)
                            throws Exception
        Transforms the value.
        Parameters:
        x - the value to transform
        Returns:
        the computed value
        Throws:
        Exception - if evaluation of formula fails
      • inverse

        protected double inverse​(double x)
                          throws Exception
        Inverse transforms the value.
        Parameters:
        x - the value to inverse transform
        Returns:
        the computed value
        Throws:
        Exception - if evaluation of formula fails
      • buildClassifier

        public void buildClassifier​(weka.core.Instances data)
                             throws Exception
        Builds the classifier.
        Parameters:
        data - the training data
        Throws:
        Exception - if something goes wrong
      • 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
      • toString

        public String toString()
        Returns description of classifier.
        Overrides:
        toString in class Object
        Returns:
        the description
      • 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[] args)
        Main method for running this class.
        Parameters:
        args - the options