public class RemoveFrequentValues extends Filter implements OptionHandler, UnsupervisedFilter
-C <num> Choose attribute to be used for selection.
-N <num> Number of values to retain for the sepcified attribute, i.e. the ones with the most instances (default 2).
-L Instead of values with the most instances the ones with the least are retained.
-H When selecting on nominal attributes, removes header references to excluded values.
-V Invert matching sense.
Modifier and Type | Field and Description |
---|---|
protected boolean |
m_Invert
whether to invert the matching sense.
|
protected boolean |
m_LeastValues
whether to retain values with least instances instead of most.
|
protected boolean |
m_ModifyHeader
Modify header for nominal attributes?
|
protected int[] |
m_NominalMapping
If m_ModifyHeader, stores a mapping from old to new indexes
|
protected int |
m_NumValues
the number of values to retain.
|
protected HashSet |
m_Values
contains the values to retain
|
m_FirstBatchDone, m_InputRelAtts, m_InputStringAtts, m_NewBatch, m_OutputRelAtts, m_OutputStringAtts
Constructor and Description |
---|
RemoveFrequentValues() |
Modifier and Type | Method and Description |
---|---|
String |
attributeIndexTipText()
Returns the tip text for this property
|
boolean |
batchFinished()
Signifies that this batch of input to the filter is finished.
|
void |
determineValues(Instances inst)
determines the values to retain, it is always at least 1
and up to the maximum number of distinct values
|
String |
getAttributeIndex()
Get the index of the attribute used.
|
Capabilities |
getCapabilities()
Returns the Capabilities of this filter.
|
boolean |
getInvertSelection()
Get whether the supplied columns are to be removed or kept
|
boolean |
getModifyHeader()
Gets whether the header will be modified when selecting on nominal
attributes.
|
int |
getNumValues()
Gets how many values are retained
|
String[] |
getOptions()
Gets the current settings of the filter.
|
String |
getRevision()
Returns the revision string.
|
boolean |
getUseLeastValues()
Gets whether to use values with least or most instances
|
String |
globalInfo()
Returns a string describing this filter
|
boolean |
input(Instance instance)
Input an instance for filtering.
|
String |
invertSelectionTipText()
Returns the tip text for this property
|
boolean |
isNominal()
Returns true if selection attribute is nominal.
|
Enumeration |
listOptions()
Returns an enumeration describing the available options.
|
static void |
main(String[] argv)
Main method for testing this class.
|
protected Instances |
modifyHeader(Instances instanceInfo)
modifies the header of the Instances and returns the format w/o
any instances
|
String |
modifyHeaderTipText()
Returns the tip text for this property
|
String |
numValuesTipText()
Returns the tip text for this property
|
void |
setAttributeIndex(String attIndex)
Sets index of the attribute used.
|
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 |
setModifyHeader(boolean newModifyHeader)
Sets whether the header will be modified when selecting on nominal
attributes.
|
void |
setNumValues(int numValues)
Sets how many values are retained
|
void |
setOptions(String[] options)
Parses a given list of options.
|
protected void |
setOutputFormat()
Set the output format.
|
void |
setUseLeastValues(boolean leastValues)
Sets whether to use values with least or most instances
|
String |
useLeastValuesTipText()
Returns the tip text for this property
|
batchFilterFile, bufferInput, copyValues, copyValues, filterFile, flushInput, getCapabilities, getInputFormat, getOutputFormat, initInputLocators, initOutputLocators, inputFormatPeek, isFirstBatchDone, isNewBatch, isOutputFormatDefined, makeCopies, makeCopy, numPendingOutput, output, outputFormatPeek, outputPeek, push, resetQueue, runFilter, setOutputFormat, testInputFormat, toString, useFilter, wekaStaticWrapper
protected int m_NumValues
protected boolean m_LeastValues
protected boolean m_Invert
protected boolean m_ModifyHeader
protected int[] m_NominalMapping
protected HashSet m_Values
public String globalInfo()
public Enumeration listOptions()
listOptions
in interface OptionHandler
public void setOptions(String[] options) throws Exception
-C <num> Choose attribute to be used for selection.
-N <num> Number of values to retain for the sepcified attribute, i.e. the ones with the most instances (default 2).
-L Instead of values with the most instances the ones with the least are retained.
-H When selecting on nominal attributes, removes header references to excluded values.
-V Invert matching sense.
setOptions
in interface OptionHandler
options
- the list of options as an array of stringsException
- if an option is not supportedpublic String[] getOptions()
getOptions
in interface OptionHandler
public String attributeIndexTipText()
public String getAttributeIndex()
public void setAttributeIndex(String attIndex)
attIndex
- the index of the attributepublic String numValuesTipText()
public int getNumValues()
public void setNumValues(int numValues)
numValues
- the number of values to retainpublic String useLeastValuesTipText()
public boolean getUseLeastValues()
public void setUseLeastValues(boolean leastValues)
leastValues
- whether values with least or most instances are retainedpublic String modifyHeaderTipText()
public boolean getModifyHeader()
public void setModifyHeader(boolean newModifyHeader)
newModifyHeader
- true if so.public String invertSelectionTipText()
public boolean getInvertSelection()
public void setInvertSelection(boolean invert)
invert
- the new invert settingpublic boolean isNominal()
public void determineValues(Instances inst)
inst
- the Instances to determine the values from which are keptprotected Instances modifyHeader(Instances instanceInfo)
instanceInfo
- the instances structure to modifypublic Capabilities getCapabilities()
getCapabilities
in interface CapabilitiesHandler
getCapabilities
in class Filter
Capabilities
public boolean setInputFormat(Instances instanceInfo) throws Exception
setInputFormat
in class Filter
instanceInfo
- an Instances object containing the input instance
structure (any instances contained in the object are ignored - only the
structure is required).UnsupportedAttributeTypeException
- if the specified attribute
is not nominal.Exception
- if the inputFormat can't be set successfullyprotected void setOutputFormat()
public boolean input(Instance instance)
input
in class Filter
instance
- the input instanceIllegalStateException
- if no input format has been set.public boolean batchFinished()
batchFinished
in class Filter
IllegalStateException
- if no input structure has been definedpublic String getRevision()
getRevision
in interface RevisionHandler
getRevision
in class Filter
public static void main(String[] argv)
argv
- should contain arguments to the filter:
use -h for helpCopyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.