Class RemoveTestInstances

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

    public class RemoveTestInstances
    extends weka.filters.SimpleBatchFilter
    implements weka.filters.UnsupervisedFilter
    Removes all instances of the provided test set from the data passing through.
    Requires an attribute in the data that uniquely identifies instances across datasets.

    Valid options are:

     -test-set <file>
      The test set to load.
     
     -use-custom-loader
      Whether to use a custom loader.
     
     -custom-loader <classname + options>
      The custom loader to use.
     
     -id <1-based index or name>
      The index/name of ID attribute to use for identifying rows.
     
     -id-test <1-based index or name>
      The index/name of ID attribute to use for identifying rows in the test set (if different from '-id').
     
     -invert
      Whether to invert the matching (ie keep rather than remove).
     
     -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).
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected weka.core.converters.AbstractFileLoader m_CustomLoader
      the file loader to use for loading the test set.
      protected WekaAttributeIndex m_ID
      the attribute to use for identifying instances.
      protected WekaAttributeIndex m_IDTest
      the attribute to use for identifying instances in the test set.
      protected boolean m_Invert
      whether to invert the matching.
      protected weka.core.Instances m_SuppliedTestSet
      the supplied test set, when using programmatically.
      protected File m_TestSet
      the file containing the test set.
      protected boolean m_UseCustomLoader
      whether to use a custom loader for the test set.
      • 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
      String customLoaderTipText()
      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.
      weka.core.Capabilities getCapabilities()
      Returns the Capabilities of this filter.
      weka.core.converters.AbstractFileLoader getCustomLoader()
      Returns the custom loader to use (if enabled).
      WekaAttributeIndex getID()
      Returns the attribute name/index to use for identifying rows.
      WekaAttributeIndex getIDTest()
      Returns the attribute name/index to use for identifying rows in the test set.
      boolean getInvert()
      Returns whether to invert the matching sense (ie keep rather than remove).
      String[] getOptions()
      Gets the current settings of the filter.
      String getRevision()
      Returns the revision string.
      weka.core.Instances getSuppliedTestSet()
      Returns the manually set test set instead of loading one from disk.
      File getTestSet()
      Returns the file containing the test set to remove from the data passing through the filter.
      boolean getUseCustomLoader()
      Returns whether to use a custom loader or automatic loading.
      String globalInfo()
      Returns a string describing this classifier.
      String IDTestTipText()
      Returns the tip text for this property.
      String IDTipText()
      Returns the tip text for this property.
      String invertTipText()
      Returns the tip text for this property.
      Enumeration listOptions()
      Returns an enumeration describing the available options.
      protected weka.core.Instances loadTestSet()
      Loads the test set from disk or returns the manually supplied one.
      static void main​(String[] args)
      Main method for testing this class.
      protected weka.core.Instances process​(weka.core.Instances instances)
      Processes the given data (may change the provided dataset) and returns the modified version.
      void setCustomLoader​(weka.core.converters.AbstractFileLoader value)
      Sets the custom loader to use (if enabled).
      void setID​(WekaAttributeIndex value)
      Sets the attribute name/index to use for identifying rows.
      void setIDTest​(WekaAttributeIndex value)
      Sets the attribute name/index to use for identifying rows in the test set.
      void setInvert​(boolean value)
      Sets whether to invert the matching sense (ie keep rather than remove).
      void setOptions​(String[] options)
      Parses a list of options for this object.
      void setSuppliedTestSet​(weka.core.Instances value)
      Sets the test set to use instead of loading one from disk.
      void setTestSet​(File value)
      Sets the file containing the test set to remove from the data passing through the filter.
      void setUseCustomLoader​(boolean value)
      Sets whether to use a custom loader or automatic loading.
      String testSetTipText()
      Returns the tip text for this property.
      String useCustomLoaderTipText()
      Returns the tip text for this property.
      • Methods inherited from class weka.filters.SimpleBatchFilter

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

        reset, setInputFormat
      • Methods inherited from class weka.filters.Filter

        batchFilterFile, bufferInput, copyValues, copyValues, debugTipText, doNotCheckCapabilitiesTipText, filterFile, flushInput, getCapabilities, 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_TestSet

        protected File m_TestSet
        the file containing the test set.
      • m_UseCustomLoader

        protected boolean m_UseCustomLoader
        whether to use a custom loader for the test set.
      • m_CustomLoader

        protected weka.core.converters.AbstractFileLoader m_CustomLoader
        the file loader to use for loading the test set.
      • m_IDTest

        protected WekaAttributeIndex m_IDTest
        the attribute to use for identifying instances in the test set.
      • m_Invert

        protected boolean m_Invert
        whether to invert the matching.
      • m_SuppliedTestSet

        protected weka.core.Instances m_SuppliedTestSet
        the supplied test set, when using programmatically.
    • Constructor Detail

      • RemoveTestInstances

        public RemoveTestInstances()
    • Method Detail

      • globalInfo

        public String globalInfo()
        Returns a string describing this classifier.
        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.
        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
      • setTestSet

        public void setTestSet​(File value)
        Sets the file containing the test set to remove from the data passing through the filter.
        Parameters:
        value - the file
      • getTestSet

        public File getTestSet()
        Returns the file containing the test set to remove from the data passing through the filter.
        Returns:
        the file
      • testSetTipText

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

        public void setUseCustomLoader​(boolean value)
        Sets whether to use a custom loader or automatic loading.
        Parameters:
        value - true if to use custom loader
      • getUseCustomLoader

        public boolean getUseCustomLoader()
        Returns whether to use a custom loader or automatic loading.
        Returns:
        true if using custom loader
      • useCustomLoaderTipText

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

        public void setCustomLoader​(weka.core.converters.AbstractFileLoader value)
        Sets the custom loader to use (if enabled).
        Parameters:
        value - the custom loader
      • getCustomLoader

        public weka.core.converters.AbstractFileLoader getCustomLoader()
        Returns the custom loader to use (if enabled).
        Returns:
        the custom loader
      • customLoaderTipText

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

        public void setID​(WekaAttributeIndex value)
        Sets the attribute name/index to use for identifying rows.
        Parameters:
        value - the attribute name/index
      • getID

        public WekaAttributeIndex getID()
        Returns the attribute name/index to use for identifying rows.
        Returns:
        the attribute name/index
      • IDTipText

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

        public void setIDTest​(WekaAttributeIndex value)
        Sets the attribute name/index to use for identifying rows in the test set.
        Parameters:
        value - the attribute name/index
      • getIDTest

        public WekaAttributeIndex getIDTest()
        Returns the attribute name/index to use for identifying rows in the test set.
        Returns:
        the attribute name/index
      • IDTestTipText

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

        public void setInvert​(boolean value)
        Sets whether to invert the matching sense (ie keep rather than remove).
        Parameters:
        value - true if to invert
      • getInvert

        public boolean getInvert()
        Returns whether to invert the matching sense (ie keep rather than remove).
        Returns:
        true if to invert
      • invertTipText

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

        public void setSuppliedTestSet​(weka.core.Instances value)
        Sets the test set to use instead of loading one from disk.
        Parameters:
        value - the test set to use, null to remove
      • getSuppliedTestSet

        public weka.core.Instances getSuppliedTestSet()
        Returns the manually set test set instead of loading one from disk.
        Returns:
        the manually set test set to use, null if to load one from disk
      • getCapabilities

        public weka.core.Capabilities getCapabilities()
        Returns the Capabilities of this filter.
        Specified by:
        getCapabilities in interface weka.core.CapabilitiesHandler
        Overrides:
        getCapabilities in class weka.filters.Filter
        Returns:
        the capabilities of this object
        See Also:
        Capabilities
      • determineOutputFormat

        protected weka.core.Instances determineOutputFormat​(weka.core.Instances inputFormat)
                                                     throws Exception
        Determines the output format based on the input format and returns this.
        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
      • loadTestSet

        protected weka.core.Instances loadTestSet()
                                           throws Exception
        Loads the test set from disk or returns the manually supplied one.
        Returns:
        the dataset
        Throws:
        Exception - if loader fails
        See Also:
        getSuppliedTestSet()
      • 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 testing this class.
        Parameters:
        args - should contain arguments to the filter: use -h for help