Class MetaPartitionedMultiFilter
- java.lang.Object
-
- weka.filters.Filter
-
- weka.filters.SimpleFilter
-
- weka.filters.SimpleBatchFilter
-
- weka.filters.unsupervised.attribute.MetaPartitionedMultiFilter
-
- All Implemented Interfaces:
Serializable,weka.core.CapabilitiesHandler,weka.core.CapabilitiesIgnorer,weka.core.CommandlineRunnable,weka.core.OptionHandler,weka.core.RevisionHandler
public class MetaPartitionedMultiFilter extends weka.filters.SimpleBatchFilterWith each specified filter, a regular expression is associated that defines the range of attributes to apply the filter to. This is used to configure a weka.filters.unsupervised.attribute.PartitionedMultiFilter internally to filter that actual data.
Unused attributes can be discarded as well.
Valid options are:
-D Turns on output of debugging information.
-F <classname [options]> A filter to apply (can be specified multiple times).
-R <regexp> A regular expression for matching attribute names (can be specified multiple times). For each filter an expression must be supplied.
-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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected PartitionedMultiFilter2m_ActualFilterthe actual filter used internally for filtering the data.protected weka.filters.Filter[]m_FiltersThe filters.protected adams.core.base.BaseString[]m_PrefixesThe prefixes.protected adams.core.base.BaseRegExp[]m_RegExpThe prefixes.protected booleanm_RemoveUnusedWhether unused attributes are left out of the output.
-
Constructor Summary
Constructors Constructor Description MetaPartitionedMultiFilter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 on the input format and returns this.StringfiltersTipText()Returns the tip text for this property.weka.core.CapabilitiesgetCapabilities()Returns the Capabilities of this filter.weka.core.CapabilitiesgetCapabilities(weka.core.Instances data)Returns the Capabilities of this filter, customized based on the data.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.adams.core.base.BaseRegExp[]getRegExp()Gets the list of regular expressions.adams.core.base.BaseRegExpgetRegExp(int index)Gets a singleBaseRegExpfrom the set of available expressions.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.EnumerationlistOptions()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.StringregExpTipText()Returns the tip text for this property.StringremoveUnusedTipText()Returns the tip text for this property.protected voidreset()resets the filter.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.voidsetRegExp(adams.core.base.BaseRegExp[] value)Sets the list of possible regular expressions.voidsetRemoveUnused(boolean value)Sets whether unused attributes (ones that are not covered by any of the ranges) are removed from the output.-
Methods inherited from class weka.filters.SimpleBatchFilter
allowAccessToFullInputFormat, batchFinished, hasImmediateOutputFormat, input
-
Methods inherited from class weka.filters.Filter
batchFilterFile, bufferInput, copyValues, copyValues, debugTipText, doNotCheckCapabilitiesTipText, filterFile, flushInput, 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_RegExp
protected adams.core.base.BaseRegExp[] m_RegExp
The prefixes.
-
m_Filters
protected weka.filters.Filter[] m_Filters
The filters.
-
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_ActualFilter
protected PartitionedMultiFilter2 m_ActualFilter
the actual filter used internally for filtering the data.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing this filter.- 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.
Valid options are:
-D Turns on output of debugging information.
-F <classname [options]> A filter to apply (can be specified multiple times).
-R <regexp> A regular expression for matching attribute names (can be specified multiple times). For each filter an expression must be supplied.
-U Flag for leaving unused attributes out of the output, by default these are included in the filter output.
- 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
-
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:
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
-
setRegExp
public void setRegExp(adams.core.base.BaseRegExp[] value)
Sets the list of possible regular expressions. Also resets the state of the Range (this reset doesn't affect the options).- Parameters:
value- an array of regular expressions- See Also:
reset()
-
getRegExp
public adams.core.base.BaseRegExp[] getRegExp()
Gets the list of regular expressions.- Returns:
- the array of expressions
-
regExpTipText
public String regExpTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getRegExp
public adams.core.base.BaseRegExp getRegExp(int index)
Gets a singleBaseRegExpfrom the set of available expressions.- Parameters:
index- the index of the expression wanted- Returns:
- the regular expression
-
setPrefixes
public void setPrefixes(adams.core.base.BaseString[] prefixes)
Sets the list of prefixes to use.- Parameters:
prefixes- an array of prefixes- See Also:
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
-
getCapabilities
public weka.core.Capabilities getCapabilities()
Returns the Capabilities of this filter. Derived filters have to override this method to enable capabilities.- Specified by:
getCapabilitiesin interfaceweka.core.CapabilitiesHandler- Overrides:
getCapabilitiesin classweka.filters.Filter- Returns:
- the capabilities of this object
- See Also:
Capabilities
-
getCapabilities
public weka.core.Capabilities getCapabilities(weka.core.Instances data)
Returns the Capabilities of this filter, customized based on the data. I.e., if removes all class capabilities, in case there's not class attribute present or removes the NO_CLASS capability, in case that there's a class present.- Overrides:
getCapabilitiesin classweka.filters.Filter- Parameters:
data- the data to use for customization- Returns:
- the capabilities of this object, based on the data
- See Also:
getCapabilities()
-
reset
protected void reset()
resets the filter.- Overrides:
resetin classweka.filters.SimpleFilter
-
determineOutputFormat
protected weka.core.Instances determineOutputFormat(weka.core.Instances inputFormat) throws ExceptionDetermines the output format based on the input format and returns this. 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
-
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 executing this class.- Parameters:
args- should contain arguments for the filter: use -h for help
-
-