Class MetaPartitionedMultiFilter

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

    public class MetaPartitionedMultiFilter
    extends weka.filters.SimpleBatchFilter
    With each specified filter, a regular expression is associated that defines the range of attributes to apply the filter to. This is used to configure a weka.filters.unsupervised.attribute.PartitionedMultiFilter internally to filter that actual data.
    Unused attributes can be discarded as well.

    Valid options are:

     -D
      Turns on output of debugging information.
     -F <classname [options]>
      A filter to apply (can be specified multiple times).
     -R <regexp>
      A regular expression for matching attribute names
      (can be specified multiple times).
      For each filter an expression must be supplied.
     -U
      Flag for leaving unused attributes out of the output, by default
      these are included in the filter output.
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected PartitionedMultiFilter2 m_ActualFilter
      the actual filter used internally for filtering the data.
      protected weka.filters.Filter[] m_Filters
      The filters.
      protected BaseString[] m_Prefixes
      The prefixes.
      protected BaseRegExp[] m_RegExp
      The prefixes.
      protected boolean m_RemoveUnused
      Whether unused attributes are left out of the output.
      • Fields inherited from class weka.filters.Filter

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

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void checkDimensions()
      checks whether the dimensions of filters and ranges fit together.
      protected weka.core.Instances determineOutputFormat​(weka.core.Instances inputFormat)
      Determines the output format based on the input format and returns this.
      String filtersTipText()
      Returns the tip text for this property.
      weka.core.Capabilities getCapabilities()
      Returns the Capabilities of this filter.
      weka.core.Capabilities getCapabilities​(weka.core.Instances data)
      Returns the Capabilities of this filter, customized based on the data.
      weka.filters.Filter getFilter​(int index)
      Gets a single filter from the set of available filters.
      weka.filters.Filter[] getFilters()
      Gets the list of possible filters to choose from.
      protected String getFilterSpec​(weka.filters.Filter filter)
      returns the filter classname and the options as one string.
      String[] getOptions()
      Gets the current settings of the filter.
      BaseString[] getPrefixes()
      Gets the list of prefixes to use.
      BaseRegExp[] getRegExp()
      Gets the list of regular expressions.
      BaseRegExp getRegExp​(int index)
      Gets a single BaseRegExp from the set of available expressions.
      boolean getRemoveUnused()
      Gets whether unused attributes (ones that are not covered by any of the ranges) are removed from the output.
      String getRevision()
      Returns the revision string.
      String globalInfo()
      Returns a string describing this filter.
      Enumeration listOptions()
      Returns an enumeration describing the available options.
      static void main​(String[] args)
      Main method for executing this class.
      String prefixesTipText()
      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.
      String regExpTipText()
      Returns the tip text for this property.
      String removeUnusedTipText()
      Returns the tip text for this property.
      protected void reset()
      resets the filter.
      void setFilters​(weka.filters.Filter[] filters)
      Sets the list of possible filters to choose from.
      void setOptions​(String[] options)
      Parses a list of options for this object.
      void setPrefixes​(BaseString[] prefixes)
      Sets the list of prefixes to use.
      void setRegExp​(BaseRegExp[] value)
      Sets the list of possible regular expressions.
      void setRemoveUnused​(boolean value)
      Sets whether unused attributes (ones that are not covered by any of the ranges) are removed from the output.
      • 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, getCopyOfInputFormat, getDebug, getDoNotCheckCapabilities, getInputFormat, getOutputFormat, 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

      • m_RegExp

        protected BaseRegExp[] m_RegExp
        The prefixes.
      • m_Filters

        protected weka.filters.Filter[] m_Filters
        The filters.
      • m_Prefixes

        protected BaseString[] m_Prefixes
        The prefixes.
      • m_RemoveUnused

        protected boolean m_RemoveUnused
        Whether unused attributes are left out of the output.
      • m_ActualFilter

        protected PartitionedMultiFilter2 m_ActualFilter
        the actual filter used internally for filtering the data.
    • Constructor Detail

      • MetaPartitionedMultiFilter

        public MetaPartitionedMultiFilter()
    • 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 classifier 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.filters.Filter
        Returns:
        an enumeration of all the available options.
      • setOptions

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

        Valid options are:

         -D
          Turns on output of debugging information.
         -F <classname [options]>
          A filter to apply (can be specified multiple times).
         -R <regexp>
          A regular expression for matching attribute names
          (can be specified multiple times).
          For each filter an expression must be supplied.
         -U
          Flag for leaving unused attributes out of the output, by default
          these are included in the filter output.
        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 settings of the filter.
        Specified by:
        getOptions in interface weka.core.OptionHandler
        Overrides:
        getOptions in class weka.filters.Filter
        Returns:
        an array of strings suitable for passing to setOptions
      • checkDimensions

        protected void checkDimensions()
                                throws Exception
        checks whether the dimensions of filters and ranges fit together.
        Throws:
        Exception - if dimensions differ
      • setRemoveUnused

        public void setRemoveUnused​(boolean value)
        Sets whether unused attributes (ones that are not covered by any of the ranges) are removed from the output.
        Parameters:
        value - if true then the unused attributes get removed
      • getRemoveUnused

        public boolean getRemoveUnused()
        Gets whether unused attributes (ones that are not covered by any of the ranges) are removed from the output.
        Returns:
        true if unused attributes are removed
      • removeUnusedTipText

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

        public void setFilters​(weka.filters.Filter[] filters)
        Sets the list of possible filters to choose from. Also resets the state of the filter (this reset doesn't affect the options).
        Parameters:
        filters - an array of filters with all options set.
        See Also:
        reset()
      • getFilters

        public weka.filters.Filter[] getFilters()
        Gets the list of possible filters to choose from.
        Returns:
        the array of Filters
      • filtersTipText

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

        public weka.filters.Filter getFilter​(int index)
        Gets a single filter from the set of available filters.
        Parameters:
        index - the index of the filter wanted
        Returns:
        the Filter
      • getFilterSpec

        protected String getFilterSpec​(weka.filters.Filter filter)
        returns the filter classname and the options as one string.
        Parameters:
        filter - the filter to get the specs for
        Returns:
        the classname plus options
      • setRegExp

        public void setRegExp​(BaseRegExp[] value)
        Sets the list of possible regular expressions. Also resets the state of the Range (this reset doesn't affect the options).
        Parameters:
        value - an array of regular expressions
        See Also:
        reset()
      • getRegExp

        public BaseRegExp[] getRegExp()
        Gets the list of regular expressions.
        Returns:
        the array of expressions
      • regExpTipText

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

        public BaseRegExp getRegExp​(int index)
        Gets a single BaseRegExp from the set of available expressions.
        Parameters:
        index - the index of the expression wanted
        Returns:
        the regular expression
      • setPrefixes

        public void setPrefixes​(BaseString[] prefixes)
        Sets the list of prefixes to use.
        Parameters:
        prefixes - an array of prefixes
        See Also:
        reset()
      • getPrefixes

        public BaseString[] getPrefixes()
        Gets the list of prefixes to use.
        Returns:
        the array of prefixes
      • prefixesTipText

        public String prefixesTipText()
        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 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
      • getCapabilities

        public weka.core.Capabilities getCapabilities​(weka.core.Instances data)
        Returns the Capabilities of this filter, customized based on the data. I.e., if removes all class capabilities, in case there's not class attribute present or removes the NO_CLASS capability, in case that there's a class present.
        Overrides:
        getCapabilities in class weka.filters.Filter
        Parameters:
        data - the data to use for customization
        Returns:
        the capabilities of this object, based on the data
        See Also:
        getCapabilities()
      • reset

        protected void reset()
        resets the filter.
        Overrides:
        reset in class weka.filters.SimpleFilter
      • 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., immediateOutputFormat() returns false, then this method will be called from batchFinished().
        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.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
      • getRevision

        public String getRevision()
        Returns the revision string.
        Specified by:
        getRevision in interface weka.core.RevisionHandler
        Overrides:
        getRevision in class weka.filters.Filter
        Returns:
        the revision
      • main

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