Class AddExpression

    • Constructor Detail

      • AddExpression

        public AddExpression()
    • Method Detail

      • globalInfo

        public String globalInfo()
        Returns a string describing this filter
        Returns:
        a description of the filter suitable for displaying in the explorer/experimenter gui
      • setOptions

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

        Valid options are:

         -E <expression>
          Specify the expression to apply. Eg a1^2*a5/log(a7*4.0).
          Supported opperators: ,+, -, *, /, ^, log, abs, cos, 
          exp, sqrt, floor, ceil, rint, tan, sin, (, )
          (default: a1^2)
         
         -N <name>
          Specify the name for the new attribute. (default is the expression provided with -E)
         
        Specified by:
        setOptions in interface OptionHandler
        Overrides:
        setOptions in class Filter
        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 filter.
        Specified by:
        getOptions in interface OptionHandler
        Overrides:
        getOptions in class Filter
        Returns:
        an array of strings suitable for passing to setOptions
      • nameTipText

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

        public void setName​(String name)
        Set the name for the new attribute. The string "expression" can be used to make the name of the new attribute equal to the expression provided.
        Parameters:
        name - the name of the new attribute
      • getName

        public String getName()
        Returns the name of the new attribute
        Returns:
        the name of the new attribute
      • expressionTipText

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

        public void setExpression​(String expr)
        Set the expression to apply
        Parameters:
        expr - a mathematical expression to apply
      • getExpression

        public String getExpression()
        Get the expression
        Returns:
        the expression
      • setInputFormat

        public boolean setInputFormat​(Instances instanceInfo)
                               throws Exception
        Sets the format of the input instances.
        Overrides:
        setInputFormat in class Filter
        Parameters:
        instanceInfo - an Instances object containing the input instance structure (any instances contained in the object are ignored - only the structure is required).
        Returns:
        true if the outputFormat may be collected immediately
        Throws:
        Exception - if the format couldn't be set successfully
      • input

        public boolean input​(Instance instance)
                      throws Exception
        Input an instance for filtering. Ordinarily the instance is processed and made available for output immediately. Some filters require all instances be read before producing output.
        Overrides:
        input in class Filter
        Parameters:
        instance - the input instance
        Returns:
        true if the filtered instance may now be collected with output().
        Throws:
        IllegalStateException - if no input format has been defined.
        Exception - if there was a problem during the filtering.
      • main

        public static void main​(String[] args)
        Main method for testing this class.
        Parameters:
        args - should contain arguments to the filter: use -h for help