All Packages Class Hierarchy This Package Previous Next Index WEKA's home
Class weka.filters.InstanceFilter
java.lang.Object
|
+----weka.filters.Filter
|
+----weka.filters.InstanceFilter
- public class InstanceFilter
- extends Filter
- implements OptionHandler
Filters instances according to the value of an attribute.
Valid filter-specific options are:
-C num
Choose attribute to be used for selection (default last).
-S num
Numeric value to be used for selection on numeric attribute.
(Instances with values smaller than given value.)
-L index1,index2-index4,...
Range of label indices to be used for selection on nominal attribute.
(First and last are valid indexes.)
-V
Invert matching sense.
-H
When selecting on nominal attributes, removes header references to
excluded values.
- Version:
- $Revision: 1.3 $
- Author:
- Eibe Frank (eibe@cs.waikato.ac.nz)
-
InstanceFilter()
-
-
getAttributeIndex()
- Get the attribute to be used for selection (-1 for last)
-
getInvertSelection()
- Get whether the supplied columns are to be removed or kept
-
getModifyHeader()
- Gets whether the header will be modified when selecting on nominal
attributes.
-
getNominalIndices()
- Get the set of nominal value indices that will be used for selection
-
getOptions()
- Gets the current settings of the filter.
-
getSplitPoint()
- Get the split point used for numeric selection
-
input(Instance)
- Input an instance for filtering.
-
inputFormat(Instances)
- Sets the format of the input instances.
-
isNominal()
-
Returns true if selection attribute is nominal.
-
isNumeric()
-
Returns true if selection attribute is numeric.
-
listOptions()
- Returns an enumeration describing the available options
-
main(String[])
- Main method for testing this class.
-
setAttributeIndex(int)
- Sets attribute to be used for selection
-
setInvertSelection(boolean)
- Set whether selected values should be removed or kept.
-
setModifyHeader(boolean)
- Sets whether the header will be modified when selecting on nominal
attributes.
-
setNominalIndices(String)
- Set which nominal labels are to be included in the selection.
-
setNominalIndicesArr(int[])
- Set which values of a nominal attribute are to be used for
selection.
-
setOptions(String[])
- Parses a given list of options.
-
setSplitPoint(double)
- Split point to be used for selection on numeric attribute.
InstanceFilter
public InstanceFilter()
listOptions
public Enumeration listOptions()
- Returns an enumeration describing the available options
- Returns:
- an enumeration of all the available options
setOptions
public void setOptions(String options[]) throws Exception
- Parses a given list of options.
Valid options are:
-C num
Choose attribute to be used for selection (default last).
-S num
Numeric value to be used for selection on numeric attribute.
(Instances with values smaller than given value.)
-L index1,index2-index4,...
Range of label indices to be used for selection on nominal attribute.
(First and last are valid indexes.)
-V
Invert matching sense.
-H
When selecting on nominal attributes, removes header references to
excluded values.
- 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.
- Returns:
- an array of strings suitable for passing to setOptions
inputFormat
public boolean inputFormat(Instances instanceInfo) throws Exception
- Sets the format of the input instances.
- Parameters:
- instanceInfo - an Instances object containing the input instance
structure (any instances contained in the object are ignored - only the
structure is required).
- Throws: Exception
- if selection is not possible
- Overrides:
- inputFormat in class Filter
input
public boolean input(Instance instance) throws Exception
- 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.
- Parameters:
- instance - the input instance
- Returns:
- true if the filtered instance may now be
collected with output().
- Throws: Exception
- if the input instance was not of the correct
format or if there was a problem with the filtering.
- Overrides:
- input in class Filter
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
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.
getAttributeIndex
public int getAttributeIndex()
- Get the attribute to be used for selection (-1 for last)
- Returns:
- the attribute index
setAttributeIndex
public void setAttributeIndex(int attribute)
- Sets attribute to be used for selection
- Parameters:
- attribute - the attribute's index (-1 for last);
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
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
getNominalIndices
public String 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
public void setNominalIndices(String rangeList) throws Exception
- 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
- Throws: Exception
- if an invalid range list is supplied
setNominalIndicesArr
public void setNominalIndicesArr(int values[]) throws Exception
- 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
- Throws: Exception
- if an invalid set of ranges is supplied
main
public static void main(String argv[])
- Main method for testing this class.
- Parameters:
- argv - should contain arguments to the filter:
use -h for help
All Packages Class Hierarchy This Package Previous Next Index WEKA's home