Class PartitionedMultiFilter2
- java.lang.Object
-
- weka.filters.Filter
-
- weka.filters.SimpleFilter
-
- weka.filters.SimpleBatchFilter
-
- weka.filters.unsupervised.attribute.PartitionedMultiFilter2
-
- All Implemented Interfaces:
Serializable,weka.core.CapabilitiesHandler,weka.core.CapabilitiesIgnorer,weka.core.CommandlineRunnable,weka.core.OptionHandler,weka.core.RevisionHandler
public class PartitionedMultiFilter2 extends weka.filters.SimpleBatchFilterA filter that applies filters on subsets of attributes and assembles the output into a new dataset. Attributes that are not covered by any of the ranges can be either retained or removed from the output. Valid options are:-D Turns on output of debugging information.
-F <classname [options]> A filter to apply (can be specified multiple times).
-R <range> An attribute range (can be specified multiple times). For each filter a range must be supplied. 'first' and 'last' are valid indices. 'inv(...)' around the range denotes an inverted range.
-U Flag for leaving unused attributes out of the output, by default these are included in the filter output.
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
StreamableFilter, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected weka.filters.Filter[]m_FiltersThe filters.protected int[]m_IndicesUnusedthe indices of the unused attributes.protected adams.core.base.BaseString[]m_PrefixesThe prefixes.protected weka.core.Instances[]m_Processedtemporary filter results when determining output format to avoid duplicate processing of data.protected weka.core.Range[]m_RangesThe attribute ranges.protected booleanm_RemoveUnusedWhether unused attributes are left out of the output.
-
Constructor Summary
Constructors Constructor Description PartitionedMultiFilter2()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanallowAccessToFullInputFormat()Returns whether to allow the determineOutputFormat(Instances) method access to the full dataset rather than just the header.protected voidcheckDimensions()checks whether the dimensions of filters and ranges fit together.protected weka.core.InstancesdetermineOutputFormat(weka.core.Instances inputFormat)Determines the output format based only on the full input dataset and returns this otherwise null is returned.protected voiddetermineUnusedIndices(weka.core.Instances data)determines the indices of unused attributes (ones that are not covered by any of the range).StringfiltersTipText()Returns the tip text for this property.protected weka.core.InstancesgenerateSubset(weka.core.Instances data, weka.core.Range range)generates a subset of the dataset with only the attributes from the range (class is always added if present).weka.core.CapabilitiesgetCapabilities()Returns the Capabilities of this filter.weka.filters.FiltergetFilter(int index)Gets a single filter from the set of available filters.weka.filters.Filter[]getFilters()Gets the list of possible filters to choose from.protected StringgetFilterSpec(weka.filters.Filter filter)returns the filter classname and the options as one string.String[]getOptions()Gets the current settings of the filter.adams.core.base.BaseString[]getPrefixes()Gets the list of prefixes to use.weka.core.RangegetRange(int index)Gets a single Range from the set of available Ranges.weka.core.Range[]getRanges()Gets the list of possible Ranges to choose from.booleangetRemoveUnused()Gets whether unused attributes (ones that are not covered by any of the ranges) are removed from the output.StringgetRevision()Returns the revision string.StringglobalInfo()Returns a string describing this filter.Enumeration<weka.core.Option>listOptions()Returns an enumeration describing the available options.static voidmain(String[] args)Main method for executing this class.StringprefixesTipText()Returns the tip text for this property.protected weka.core.Instancesprocess(weka.core.Instances instances)Processes the given data (may change the provided dataset) and returns the modified version.StringrangesTipText()Returns the tip text for this property.StringremoveUnusedTipText()Returns the tip text for this property.protected weka.core.InstancesrenameAttributes(weka.core.Instances data, String prefix)renames all the attributes in the dataset (excluding the class if present) by adding the prefix to the name.voidsetFilters(weka.filters.Filter[] filters)Sets the list of possible filters to choose from.voidsetOptions(String[] options)Parses a list of options for this object.voidsetPrefixes(adams.core.base.BaseString[] prefixes)Sets the list of prefixes to use.voidsetRanges(weka.core.Range[] Ranges)Sets the list of possible Ranges to choose from.voidsetRemoveUnused(boolean value)Sets whether unused attributes (ones that are not covered by any of the ranges) are removed from the output.protected voidtestInputFormat(weka.core.Instances instanceInfo)tests the data whether the filter can actually handle it.-
Methods inherited from class weka.filters.SimpleBatchFilter
batchFinished, hasImmediateOutputFormat, input
-
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, toString, useFilter, wekaStaticWrapper
-
-
-
-
Field Detail
-
m_Filters
protected weka.filters.Filter[] m_Filters
The filters.
-
m_Ranges
protected weka.core.Range[] m_Ranges
The attribute ranges.
-
m_Prefixes
protected adams.core.base.BaseString[] m_Prefixes
The prefixes.
-
m_RemoveUnused
protected boolean m_RemoveUnused
Whether unused attributes are left out of the output.
-
m_IndicesUnused
protected int[] m_IndicesUnused
the indices of the unused attributes.
-
m_Processed
protected weka.core.Instances[] m_Processed
temporary filter results when determining output format to avoid duplicate processing of data.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing this filter.- Specified by:
globalInfoin classweka.filters.SimpleFilter- Returns:
- a description of the filter suitable for displaying in the explorer/experimenter gui
-
listOptions
public Enumeration<weka.core.Option> 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
-
checkDimensions
protected void checkDimensions() throws Exceptionchecks whether the dimensions of filters and ranges fit together.- Throws:
Exception- if dimensions differ
-
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
-
testInputFormat
protected void testInputFormat(weka.core.Instances instanceInfo) throws Exceptiontests the data whether the filter can actually handle it.- Overrides:
testInputFormatin classweka.filters.Filter- Parameters:
instanceInfo- the data to test- Throws:
Exception- if the test fails
-
setRemoveUnused
public void setRemoveUnused(boolean value)
Sets whether unused attributes (ones that are not covered by any of the ranges) are removed from the output.- Parameters:
value- if true then the unused attributes get removed
-
getRemoveUnused
public boolean getRemoveUnused()
Gets whether unused attributes (ones that are not covered by any of the ranges) are removed from the output.- Returns:
- true if unused attributes are removed
-
removeUnusedTipText
public String removeUnusedTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setFilters
public void setFilters(weka.filters.Filter[] filters)
Sets the list of possible filters to choose from. Also resets the state of the filter (this reset doesn't affect the options).- Parameters:
filters- an array of filters with all options set.- See Also:
SimpleFilter.reset()
-
getFilters
public weka.filters.Filter[] getFilters()
Gets the list of possible filters to choose from.- Returns:
- the array of Filters
-
filtersTipText
public String filtersTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getFilter
public weka.filters.Filter getFilter(int index)
Gets a single filter from the set of available filters.- Parameters:
index- the index of the filter wanted- Returns:
- the Filter
-
getFilterSpec
protected String getFilterSpec(weka.filters.Filter filter)
returns the filter classname and the options as one string.- Parameters:
filter- the filter to get the specs for- Returns:
- the classname plus options
-
setRanges
public void setRanges(weka.core.Range[] Ranges)
Sets the list of possible Ranges to choose from. Also resets the state of the Range (this reset doesn't affect the options).- Parameters:
Ranges- an array of Ranges with all options set.- See Also:
SimpleFilter.reset()
-
getRanges
public weka.core.Range[] getRanges()
Gets the list of possible Ranges to choose from.- Returns:
- the array of Ranges
-
rangesTipText
public String rangesTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setPrefixes
public void setPrefixes(adams.core.base.BaseString[] prefixes)
Sets the list of prefixes to use.- Parameters:
prefixes- an array of prefixes- See Also:
SimpleFilter.reset()
-
getPrefixes
public adams.core.base.BaseString[] getPrefixes()
Gets the list of prefixes to use.- Returns:
- the array of prefixes
-
prefixesTipText
public String prefixesTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getRange
public weka.core.Range getRange(int index)
Gets a single Range from the set of available Ranges.- Parameters:
index- the index of the Range wanted- Returns:
- the Range
-
allowAccessToFullInputFormat
public boolean allowAccessToFullInputFormat()
Returns whether to allow the determineOutputFormat(Instances) method access to the full dataset rather than just the header.- Overrides:
allowAccessToFullInputFormatin classweka.filters.SimpleBatchFilter- Returns:
- whether determineOutputFormat has access to the full input dataset
-
determineUnusedIndices
protected void determineUnusedIndices(weka.core.Instances data)
determines the indices of unused attributes (ones that are not covered by any of the range).- Parameters:
data- the data to base the determination on- See Also:
m_IndicesUnused
-
generateSubset
protected weka.core.Instances generateSubset(weka.core.Instances data, weka.core.Range range) throws Exceptiongenerates a subset of the dataset with only the attributes from the range (class is always added if present).- Parameters:
data- the data to work onrange- the range of attribute to use- Returns:
- the generated subset
- Throws:
Exception- if creation fails
-
renameAttributes
protected weka.core.Instances renameAttributes(weka.core.Instances data, String prefix) throws Exceptionrenames all the attributes in the dataset (excluding the class if present) by adding the prefix to the name.- Parameters:
data- the data to work onprefix- the prefix for the attributes- Returns:
- a copy of the data with the attributes renamed
- Throws:
Exception- if renaming fails
-
determineOutputFormat
protected weka.core.Instances determineOutputFormat(weka.core.Instances inputFormat) throws ExceptionDetermines the output format based only on the full input dataset and returns this otherwise null is returned. In case the output format cannot be returned immediately, i.e., immediateOutputFormat() returns false, then this method will be called from batchFinished().- 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- See Also:
SimpleBatchFilter.hasImmediateOutputFormat(),SimpleBatchFilter.batchFinished()
-
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- See Also:
SimpleBatchFilter.batchFinished()
-
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 executing this class.- Parameters:
args- should contain arguments for the filter: use -h for help
-
-