Class EquiDistance

  • All Implemented Interfaces:
    Serializable, weka.core.CapabilitiesHandler, weka.core.CapabilitiesIgnorer, weka.core.CommandlineRunnable, weka.core.OptionHandler, weka.core.RevisionHandler

    public class EquiDistance
    extends weka.filters.SimpleBatchFilter
    A filter for interpolating the numeric attributes.Using the same number of points as are currently present in the input will have no effect.

    Valid options are:

     -num-points <value>
      The number of points to generate, '-1' will use the same amount of points as currently in the input data.
      (default: -1)
     -att-sel <value>
      Determines how the attributes are selected.
      (default: RANGE)
     -range <value>
      The range of attributes to use, if RANGE selected.
      (default: range=first-last, max=-1, inv=false)
     -regexp <value>
      The regular expression for identifying the attributes via their name, if REGEXP selected.
      (default: .*)
     -prefix <value>
      The prefix to use for the new attributes; 1-based index gets appended.
      (default: att-)
     -output-debug-info
      If set, filter is run in debug mode and
      may output additional info to the console
     -do-not-check-capabilities
      If set, filter capabilities are not checked before filter is built
      (use with caution).
    Version:
    $Revision$
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  EquiDistance.AttributeSelection
      Defines how the attributes are selected.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String ATTRIBUTE_SELECTION
      the option for the attribute selection.
      protected gnu.trove.list.TIntList m_Attributes
      the indices of the identified attributes.
      protected EquiDistance.AttributeSelection m_AttributeSelection
      how to select the attributes.
      protected double m_AverageSpacing
      the average spacing.
      protected int m_NumPoints
      the number of points to output ("-1" uses the same amount of points as currently in the data).
      protected String m_Prefix
      the prefix for the new attributes.
      protected Range m_Range
      the attribute range to use.
      protected BaseRegExp m_RegExp
      the regular expression to use.
      static String NUM_POINTS
      the option for the number of points.
      static String PREFIX
      the option for the prefix of the new attribute names.
      static String RANGE
      the option for the attribute range.
      static String REGEXP
      the option for the attribute regexp.
      • Fields inherited from class weka.filters.Filter

        m_Debug, m_DoNotCheckCapabilities, m_FirstBatchDone, m_InputRelAtts, m_InputStringAtts, m_NewBatch, m_OutputRelAtts, m_OutputStringAtts
    • Constructor Summary

      Constructors 
      Constructor Description
      EquiDistance()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      String attributeSelectionTipText()
      Returns the tip text for this property.
      protected weka.core.Instances determineOutputFormat​(weka.core.Instances inputFormat)
      Determines the output format based on the input format and returns this.
      EquiDistance.AttributeSelection getAttributeSelection()
      Returns how the attributes get selected.
      weka.core.Capabilities getCapabilities()
      Returns the Capabilities of this filter.
      protected EquiDistance.AttributeSelection getDefaultAttributeSelection()
      Returns the default attribute selection.
      protected int getDefaultNumPoints()
      Returns the default number of points.
      protected String getDefaultPrefix()
      Returns the default prefix for the new attributes.
      protected Range getDefaultRange()
      Returns the default attribute range.
      protected BaseRegExp getDefaultRegExp()
      Returns the default regular expression for identifying attributes.
      int getNumPoints()
      Returns the number of points to output.
      String[] getOptions()
      Gets the current option settings for the OptionHandler.
      String getPrefix()
      Returns the prefix for the new attributes.
      Range getRange()
      Returns the attribute range.
      BaseRegExp getRegExp()
      Returns the regular expression for identifying attributes.
      String globalInfo()
      Returns a string describing this filter.
      protected double interpolate​(double index, int indexLeft, double valueLeft, int indexRight, double valueRight)
      Returns interpolated value.
      Enumeration listOptions()
      Returns an enumeration describing the available options.
      static void main​(String[] args)
      Main method for testing this class.
      String numPointsTipText()
      Returns the tip text for this property.
      String prefixTipText()
      Returns the tip text for this property.
      protected weka.core.Instances process​(weka.core.Instances instances)
      Processes the given data (may change the provided dataset) and returns the modified version.
      protected weka.core.Instance process​(weka.core.Instances header, weka.core.Instance instance)
      processes the given instance (may change the provided instance) and returns the modified version.
      String rangeTipText()
      Returns the tip text for this property.
      String regExpTipText()
      Returns the tip text for this property.
      protected void reset()
      Resets the filter.
      void setAttributeSelection​(EquiDistance.AttributeSelection value)
      Sets how the attributes get selected.
      void setNumPoints​(int value)
      Sets the number of points to use.
      void setOptions​(String[] options)
      Sets the OptionHandler's options using the given list.
      void setPrefix​(String value)
      Sets the prefix for the new attributes.
      void setRange​(Range value)
      Sets the attribute range.
      void setRegExp​(BaseRegExp value)
      Sets the regular expression for identifying attributes.
      • Methods inherited from class weka.filters.SimpleBatchFilter

        allowAccessToFullInputFormat, batchFinished, hasImmediateOutputFormat, input, input
      • Methods inherited from class weka.filters.SimpleFilter

        setInputFormat
      • Methods inherited from class weka.filters.Filter

        batchFilterFile, bufferInput, copyValues, copyValues, debugTipText, doNotCheckCapabilitiesTipText, filterFile, flushInput, getCapabilities, getCopyOfInputFormat, getDebug, getDoNotCheckCapabilities, getInputFormat, getOutputFormat, getRevision, initInputLocators, initOutputLocators, inputFormatPeek, isFirstBatchDone, isNewBatch, isOutputFormatDefined, makeCopies, makeCopy, mayRemoveInstanceAfterFirstBatchDone, numPendingOutput, output, outputFormatPeek, outputPeek, postExecution, preExecution, push, push, resetQueue, run, runFilter, setDebug, setDoNotCheckCapabilities, setOutputFormat, testInputFormat, toString, useFilter, wekaStaticWrapper
    • Field Detail

      • ATTRIBUTE_SELECTION

        public static final String ATTRIBUTE_SELECTION
        the option for the attribute selection.
        See Also:
        Constant Field Values
      • m_NumPoints

        protected int m_NumPoints
        the number of points to output ("-1" uses the same amount of points as currently in the data).
      • m_Range

        protected Range m_Range
        the attribute range to use.
      • m_RegExp

        protected BaseRegExp m_RegExp
        the regular expression to use.
      • m_Prefix

        protected String m_Prefix
        the prefix for the new attributes.
      • m_Attributes

        protected gnu.trove.list.TIntList m_Attributes
        the indices of the identified attributes.
      • m_AverageSpacing

        protected double m_AverageSpacing
        the average spacing.
    • Constructor Detail

      • EquiDistance

        public EquiDistance()
    • Method Detail

      • globalInfo

        public String globalInfo()
        Returns a string describing this filter.
        Specified by:
        globalInfo in class weka.filters.SimpleFilter
        Returns:
        a description of the filter suitable for displaying in the explorer/experimenter gui
      • reset

        protected void reset()
        Resets the filter.
        Overrides:
        reset in class weka.filters.SimpleFilter
      • getDefaultNumPoints

        protected int getDefaultNumPoints()
        Returns the default number of points.
        Returns:
        the default
      • setNumPoints

        public void setNumPoints​(int value)
        Sets the number of points to use.
        Parameters:
        value - the number of points
      • getNumPoints

        public int getNumPoints()
        Returns the number of points to output.
        Returns:
        the number of points
      • numPointsTipText

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

        protected EquiDistance.AttributeSelection getDefaultAttributeSelection()
        Returns the default attribute selection.
        Returns:
        the default
      • setAttributeSelection

        public void setAttributeSelection​(EquiDistance.AttributeSelection value)
        Sets how the attributes get selected.
        Parameters:
        value - the selection
      • attributeSelectionTipText

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

        protected Range getDefaultRange()
        Returns the default attribute range.
        Returns:
        the default
      • rangeTipText

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

        protected BaseRegExp getDefaultRegExp()
        Returns the default regular expression for identifying attributes.
        Returns:
        the default
      • regExpTipText

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

        protected String getDefaultPrefix()
        Returns the default prefix for the new attributes.
        Returns:
        the default
      • setPrefix

        public void setPrefix​(String value)
        Sets the prefix for the new attributes.
        Parameters:
        value - the prefix
      • getPrefix

        public String getPrefix()
        Returns the prefix for the new attributes.
        Returns:
        the prefix
      • prefixTipText

        public String prefixTipText()
        Returns the tip text for this property.
        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.filters.Filter
        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.filters.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 option settings for the OptionHandler.
        Specified by:
        getOptions in interface weka.core.OptionHandler
        Overrides:
        getOptions in class weka.filters.Filter
        Returns:
        the list of current option settings as an array of strings
      • getCapabilities

        public weka.core.Capabilities getCapabilities()
        Returns the Capabilities of this filter. Derived filters have to override this method to enable capabilities.
        Specified by:
        getCapabilities in interface weka.core.CapabilitiesHandler
        Overrides:
        getCapabilities in class weka.filters.Filter
        Returns:
        the capabilities of this object
        See Also:
        Capabilities
      • interpolate

        protected double interpolate​(double index,
                                     int indexLeft,
                                     double valueLeft,
                                     int indexRight,
                                     double valueRight)
        Returns interpolated value.
        Parameters:
        index - the index we have to interpolate for
        indexLeft - the index of the "earlier" attribute
        valueLeft - the "earlier" attribute value
        indexRight - the index of the "later" attribute
        valueRight - the "later" attribute value
        Returns:
        the interpolated value
      • determineOutputFormat

        protected weka.core.Instances determineOutputFormat​(weka.core.Instances inputFormat)
                                                     throws Exception
        Determines the output format based on the input format and returns this. In case the output format cannot be returned immediately, i.e., hasImmediateOutputFormat() returns false, then this method will called from batchFinished() after the call of preprocess(Instances), in which, e.g., statistics for the actual processing step can be gathered.
        Specified by:
        determineOutputFormat in class weka.filters.SimpleFilter
        Parameters:
        inputFormat - the input format to base the output format on
        Returns:
        the output format
        Throws:
        Exception - in case the determination goes wrong
      • process

        protected weka.core.Instance process​(weka.core.Instances header,
                                             weka.core.Instance instance)
                                      throws Exception
        processes the given instance (may change the provided instance) and returns the modified version.
        Parameters:
        instance - the instance to process
        Returns:
        the modified data
        Throws:
        Exception - in case the processing goes wrong
      • process

        protected weka.core.Instances process​(weka.core.Instances instances)
                                       throws Exception
        Processes the given data (may change the provided dataset) and returns the modified version. This method is called in batchFinished().
        Specified by:
        process in class weka.filters.SimpleFilter
        Parameters:
        instances - the data to process
        Returns:
        the modified data
        Throws:
        Exception - in case the processing goes wrong
      • 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