Class RemoveTestInstances
- java.lang.Object
-
- weka.filters.Filter
-
- weka.filters.SimpleFilter
-
- weka.filters.SimpleBatchFilter
-
- weka.filters.unsupervised.instance.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.UnsupervisedFilterRemoves 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.AbstractFileLoaderm_CustomLoaderthe file loader to use for loading the test set.protected WekaAttributeIndexm_IDthe attribute to use for identifying instances.protected WekaAttributeIndexm_IDTestthe attribute to use for identifying instances in the test set.protected booleanm_Invertwhether to invert the matching.protected weka.core.Instancesm_SuppliedTestSetthe supplied test set, when using programmatically.protected Filem_TestSetthe file containing the test set.protected booleanm_UseCustomLoaderwhether to use a custom loader for the test set.
-
Constructor Summary
Constructors Constructor Description RemoveTestInstances()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringcustomLoaderTipText()Returns the tip text for this property.protected weka.core.InstancesdetermineOutputFormat(weka.core.Instances inputFormat)Determines the output format based on the input format and returns this.weka.core.CapabilitiesgetCapabilities()Returns the Capabilities of this filter.weka.core.converters.AbstractFileLoadergetCustomLoader()Returns the custom loader to use (if enabled).WekaAttributeIndexgetID()Returns the attribute name/index to use for identifying rows.WekaAttributeIndexgetIDTest()Returns the attribute name/index to use for identifying rows in the test set.booleangetInvert()Returns whether to invert the matching sense (ie keep rather than remove).String[]getOptions()Gets the current settings of the filter.StringgetRevision()Returns the revision string.weka.core.InstancesgetSuppliedTestSet()Returns the manually set test set instead of loading one from disk.FilegetTestSet()Returns the file containing the test set to remove from the data passing through the filter.booleangetUseCustomLoader()Returns whether to use a custom loader or automatic loading.StringglobalInfo()Returns a string describing this classifier.StringIDTestTipText()Returns the tip text for this property.StringIDTipText()Returns the tip text for this property.StringinvertTipText()Returns the tip text for this property.EnumerationlistOptions()Returns an enumeration describing the available options.protected weka.core.InstancesloadTestSet()Loads the test set from disk or returns the manually supplied one.static voidmain(String[] args)Main method for testing this class.protected weka.core.Instancesprocess(weka.core.Instances instances)Processes the given data (may change the provided dataset) and returns the modified version.voidsetCustomLoader(weka.core.converters.AbstractFileLoader value)Sets the custom loader to use (if enabled).voidsetID(WekaAttributeIndex value)Sets the attribute name/index to use for identifying rows.voidsetIDTest(WekaAttributeIndex value)Sets the attribute name/index to use for identifying rows in the test set.voidsetInvert(boolean value)Sets whether to invert the matching sense (ie keep rather than remove).voidsetOptions(String[] options)Parses a list of options for this object.voidsetSuppliedTestSet(weka.core.Instances value)Sets the test set to use instead of loading one from disk.voidsetTestSet(File value)Sets the file containing the test set to remove from the data passing through the filter.voidsetUseCustomLoader(boolean value)Sets whether to use a custom loader or automatic loading.StringtestSetTipText()Returns the tip text for this property.StringuseCustomLoaderTipText()Returns the tip text for this property.-
Methods inherited from class weka.filters.SimpleBatchFilter
allowAccessToFullInputFormat, batchFinished, hasImmediateOutputFormat, input, input
-
Methods inherited from class weka.filters.Filter
batchFilterFile, bufferInput, copyValues, copyValues, debugTipText, doNotCheckCapabilitiesTipText, filterFile, flushInput, getCapabilities, 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_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_ID
protected WekaAttributeIndex m_ID
the attribute to use for identifying instances.
-
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.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing this classifier.- Specified by:
globalInfoin classweka.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:
listOptionsin interfaceweka.core.OptionHandler- Overrides:
listOptionsin classweka.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:
setOptionsin interfaceweka.core.OptionHandler- Overrides:
setOptionsin classweka.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:
getOptionsin interfaceweka.core.OptionHandler- Overrides:
getOptionsin classweka.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:
getCapabilitiesin interfaceweka.core.CapabilitiesHandler- Overrides:
getCapabilitiesin classweka.filters.Filter- Returns:
- the capabilities of this object
- See Also:
Capabilities
-
determineOutputFormat
protected weka.core.Instances determineOutputFormat(weka.core.Instances inputFormat) throws ExceptionDetermines the output format based on the input format and returns this.- Specified by:
determineOutputFormatin classweka.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 ExceptionLoads 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 ExceptionProcesses the given data (may change the provided dataset) and returns the modified version. This method is called in batchFinished().- Specified by:
processin classweka.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:
getRevisionin interfaceweka.core.RevisionHandler- Overrides:
getRevisionin classweka.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
-
-