Class RemoveWithValues
java.lang.Object
weka.filters.Filter
weka.filters.unsupervised.instance.RemoveWithValues
- All Implemented Interfaces:
Serializable
,CapabilitiesHandler
,CapabilitiesIgnorer
,CommandlineRunnable
,OptionHandler
,RevisionHandler
,WeightedAttributesHandler
,WeightedInstancesHandler
,StreamableFilter
,UnsupervisedFilter
public class RemoveWithValues
extends Filter
implements UnsupervisedFilter, StreamableFilter, OptionHandler, WeightedInstancesHandler, WeightedAttributesHandler
Filters instances according to the value of an
attribute.
Valid options are:
-C <num> Choose attribute to be used for selection.
-S <num> Numeric value to be used for selection on numeric attribute. Instances with values smaller than given value will be selected. (default 0)
-L <index1,index2-index4,...> Range of label indices to be used for selection on nominal attribute. First and last are valid indexes. (default all values)
-M Missing values count as a match. This setting is independent of the -V option. (default missing values don't match)
-V Invert matching sense.
-H When selecting on nominal attributes, removes header references to excluded values.
-F Do not apply the filter to instances that arrive after the first (training) batch. The default is to apply the filter (i.e. the filter may not return an instance if it matches the remove criteria)
- Version:
- $Revision: 14508 $
- Author:
- Eibe Frank (eibe@cs.waikato.ac.nz)
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the tip text for this propertyReturns the tip text for this property.Get the index of the attribute used.Returns the Capabilities of this filter.boolean
Get whether to apply the filter to instances that arrive once the first (training) batch has been seen.boolean
Get whether the supplied columns are to be removed or keptboolean
Gets whether missing values are counted as a match.boolean
Gets whether the header will be modified when selecting on nominal attributes.Get the set of nominal value indices that will be used for selectionString[]
Gets the current settings of the filter.Returns the revision string.double
Get the split point used for numeric selectionReturns a string describing this classifierboolean
Input an instance for filtering.Returns the tip text for this propertyboolean
Returns true if selection attribute is nominal.boolean
Returns true if selection attribute is numeric.Returns an enumeration describing the available options.static void
Main method for testing this class.Returns the tip text for this propertyboolean
RemoveWithValues may return false from input() (thus not making an instance available immediately) even after the first batch has been completed due to matching a value that the user wants to remove.Returns the tip text for this propertyReturns the tip text for this propertyvoid
setAttributeIndex
(String attIndex) Sets index of the attribute used.void
setDontFilterAfterFirstBatch
(boolean b) Set whether to apply the filter to instances that arrive once the first (training) batch has been seen.boolean
setInputFormat
(Instances instanceInfo) Sets the format of the input instances.void
setInvertSelection
(boolean invert) Set whether selected values should be removed or kept.void
setMatchMissingValues
(boolean newMatchMissingValues) Sets whether missing values are counted as a match.void
setModifyHeader
(boolean newModifyHeader) Sets whether the header will be modified when selecting on nominal attributes.void
setNominalIndices
(String rangeList) Set which nominal labels are to be included in the selection.void
setNominalIndicesArr
(int[] values) Set which values of a nominal attribute are to be used for selection.void
setOptions
(String[] options) Parses a given list of options.void
setSplitPoint
(double value) Split point to be used for selection on numeric attribute.Returns the tip text for this propertyMethods inherited from class weka.filters.Filter
batchFilterFile, batchFinished, debugTipText, doNotCheckCapabilitiesTipText, filterFile, getCapabilities, getCopyOfInputFormat, getDebug, getDoNotCheckCapabilities, getOutputFormat, isFirstBatchDone, isNewBatch, isOutputFormatDefined, makeCopies, makeCopy, numPendingOutput, output, outputPeek, postExecution, preExecution, run, runFilter, setDebug, setDoNotCheckCapabilities, toString, useFilter, wekaStaticWrapper
-
Constructor Details
-
RemoveWithValues
public RemoveWithValues()Default constructor
-
-
Method Details
-
globalInfo
Returns a string describing this classifier- Returns:
- a description of the classifier suitable for displaying in the explorer/experimenter gui
-
listOptions
Returns an enumeration describing the available options.- Specified by:
listOptions
in interfaceOptionHandler
- Overrides:
listOptions
in classFilter
- Returns:
- an enumeration of all the available options.
-
setOptions
Parses a given list of options. Valid options are:-C <num> Choose attribute to be used for selection.
-S <num> Numeric value to be used for selection on numeric attribute. Instances with values smaller than given value will be selected. (default 0)
-L <index1,index2-index4,...> Range of label indices to be used for selection on nominal attribute. First and last are valid indexes. (default all values)
-M Missing values count as a match. This setting is independent of the -V option. (default missing values don't match)
-V Invert matching sense.
-H When selecting on nominal attributes, removes header references to excluded values.
-F Do not apply the filter to instances that arrive after the first (training) batch. The default is to apply the filter (i.e. the filter may not return an instance if it matches the remove criteria)
- Specified by:
setOptions
in interfaceOptionHandler
- Overrides:
setOptions
in classFilter
- Parameters:
options
- the list of options as an array of strings- Throws:
Exception
- if an option is not supported
-
getOptions
Gets the current settings of the filter.- Specified by:
getOptions
in interfaceOptionHandler
- Overrides:
getOptions
in classFilter
- Returns:
- an array of strings suitable for passing to setOptions
-
getCapabilities
Returns the Capabilities of this filter.- Specified by:
getCapabilities
in interfaceCapabilitiesHandler
- Overrides:
getCapabilities
in classFilter
- Returns:
- the capabilities of this object
- See Also:
-
setInputFormat
Sets the format of the input instances.- Overrides:
setInputFormat
in classFilter
- 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 because outputFormat can be collected immediately
- Throws:
UnsupportedAttributeTypeException
- if the specified attribute is neither numeric or nominal.Exception
- if the inputFormat can't be set successfully
-
input
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 classFilter
- 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 set.
-
mayRemoveInstanceAfterFirstBatchDone
public boolean mayRemoveInstanceAfterFirstBatchDone()RemoveWithValues may return false from input() (thus not making an instance available immediately) even after the first batch has been completed due to matching a value that the user wants to remove. Therefore this method returns true.- Overrides:
mayRemoveInstanceAfterFirstBatchDone
in classFilter
- Returns:
- true
-
isNominal
public boolean isNominal()Returns true if selection attribute is nominal.- Returns:
- true if selection attribute is nominal
-
isNumeric
public boolean isNumeric()Returns true if selection attribute is numeric.- Returns:
- true if selection attribute is numeric
-
modifyHeaderTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getModifyHeader
public boolean getModifyHeader()Gets whether the header will be modified when selecting on nominal attributes.- Returns:
- true if so.
-
setModifyHeader
public void setModifyHeader(boolean newModifyHeader) Sets whether the header will be modified when selecting on nominal attributes.- Parameters:
newModifyHeader
- true if so.
-
attributeIndexTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getAttributeIndex
Get the index of the attribute used.- Returns:
- the index of the attribute
-
setAttributeIndex
Sets index of the attribute used.- Parameters:
attIndex
- the index of the attribute
-
splitPointTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getSplitPoint
public double getSplitPoint()Get the split point used for numeric selection- Returns:
- the numeric split point
-
setSplitPoint
public void setSplitPoint(double value) Split point to be used for selection on numeric attribute.- Parameters:
value
- the split point
-
matchMissingValuesTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getMatchMissingValues
public boolean getMatchMissingValues()Gets whether missing values are counted as a match.- Returns:
- true if missing values are counted as a match.
-
setMatchMissingValues
public void setMatchMissingValues(boolean newMatchMissingValues) Sets whether missing values are counted as a match.- Parameters:
newMatchMissingValues
- true if missing values are counted as a match.
-
invertSelectionTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getInvertSelection
public boolean getInvertSelection()Get whether the supplied columns are to be removed or kept- Returns:
- true if the supplied columns will be kept
-
setInvertSelection
public void setInvertSelection(boolean invert) Set whether selected values should be removed or kept. If true the selected values are kept and unselected values are deleted.- Parameters:
invert
- the new invert setting
-
nominalIndicesTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getNominalIndices
Get the set of nominal value indices that will be used for selection- Returns:
- rangeList a string representing the list of nominal indices.
-
setNominalIndices
Set which nominal labels are to be included in the selection.- Parameters:
rangeList
- a string representing the list of nominal indices. eg: first-3,5,6-last
-
setDontFilterAfterFirstBatch
public void setDontFilterAfterFirstBatch(boolean b) Set whether to apply the filter to instances that arrive once the first (training) batch has been seen. The default is to not apply the filter and just return each instance input. This is so that, when used in the FilteredClassifier, a test instance does not get "consumed" by the filter and a prediction is always generated.- Parameters:
b
- true if the filter should *not* be applied to instances that arrive after the first (training) batch has been processed.
-
getDontFilterAfterFirstBatch
public boolean getDontFilterAfterFirstBatch()Get whether to apply the filter to instances that arrive once the first (training) batch has been seen. The default is to not apply the filter and just return each instance input. This is so that, when used in the FilteredClassifier, a test instance does not get "consumed" by the filter and a prediction is always generated.- Returns:
- true if the filter should *not* be applied to instances that arrive after the first (training) batch has been processed.
-
dontFilterAfterFirstBatchTipText
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setNominalIndicesArr
public void setNominalIndicesArr(int[] values) Set which values of a nominal attribute are to be used for selection.- Parameters:
values
- an array containing indexes of values to be used for selection
-
getRevision
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Overrides:
getRevision
in classFilter
- Returns:
- the revision
-
main
Main method for testing this class.- Parameters:
argv
- should contain arguments to the filter: use -h for help
-