Package weka.filters
Class MultiwayFilter
- java.lang.Object
-
- weka.filters.Filter
-
- weka.filters.SimpleFilter
-
- weka.filters.SimpleBatchFilter
-
- weka.filters.MultiwayFilter
-
- All Implemented Interfaces:
Serializable
,weka.core.CapabilitiesHandler
,weka.core.CapabilitiesIgnorer
,weka.core.CommandlineRunnable
,weka.core.OptionHandler
,weka.core.RevisionHandler
public class MultiwayFilter extends weka.filters.SimpleBatchFilter
Wrapper treating a multiway filter as a WEKA filter.
Valid options are:
-filter <value> The multiway filtering algorithm to use. (default: nz.ac.waikato.cms.adams.multiway.algorithm.twoway.PLS2 -debug false -num-components 5 -standardize-y true -array-stopping-criteria "nz.ac.waikato.cms.adams.multiway.algorithm.stopping.IterationCriterion -current-iteration 0 -max-iterations 250" -array-stopping-criteria "nz.ac.waikato.cms.adams.multiway.algorithm.stopping.ImprovementCriterion -tol 1.0E-7")
-output-debug-info If set, filter is run in debug mode and may output additional info to the console
-do-not-check-capabilities If set, filter capabilities are not checked before filter is built (use with caution).
- Author:
- Corey Sterling (csterlin at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected adams.flow.transformer.wekadatasetsmerge.Simple
m_ClassMerger
Merger for rejoining class attribute for supervised filters.protected adams.data.weka.datasetsplitter.ColumnSplitter
m_ClassSplitter
Splitter for removing class attribute for supervised filters.protected nz.ac.waikato.cms.adams.multiway.algorithm.api.AbstractAlgorithm
m_Filter
The multiway filtering algorithm.protected weka.core.Instances
m_FilteredTemplate
Template dataset for the filtered output.
-
Constructor Summary
Constructors Constructor Description MultiwayFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
allowAccessToFullInputFormat()
Returns whether to allow the determineOutputFormat(Instances) method access to the full dataset rather than just the header.protected weka.core.Instances
determineOutputFormat(weka.core.Instances inputFormat)
Determines the output format based on the input format and returns this.protected weka.core.Instances
emptyInstancesForTensor(int size)
Creates an empty dataset sized to match the given tensor size.String
filterTipText()
Gets the tip-text for the filter option.nz.ac.waikato.cms.adams.multiway.algorithm.api.AbstractAlgorithm
getDefaultFilter()
Gets the default multiway filtering algorithm to use.nz.ac.waikato.cms.adams.multiway.algorithm.api.AbstractAlgorithm
getFilter()
Gets the multiway filtering algorithm to use.protected nz.ac.waikato.cms.adams.multiway.algorithm.api.Filter
getFilterAsFilter()
Gets the filtering algorithm already cast to a Filter.String[]
getOptions()
returns the options of the current setupString
globalInfo()
Returns a string describing this filter.protected nz.ac.waikato.cms.adams.multiway.data.tensor.Tensor
instancesToTensor(weka.core.Instances instances)
Creates a tensor representation of the given dataset.Enumeration<weka.core.Option>
listOptions()
Gets an enumeration describing the available options.protected weka.core.Instances
process(weka.core.Instances instances)
Processes the given data (may change the provided dataset) and returns the modified version.protected weka.core.Instances
remergeClassAttribute(weka.core.Instances filtered, weka.core.Instances classSet)
Remerges the class attribute with the filtered data for supervised filters.protected void
reset()
resets the filter, i.e., m_NewBatch to true and m_FirstBatchDone to false.void
setFilter(nz.ac.waikato.cms.adams.multiway.algorithm.api.AbstractAlgorithm value)
Sets the multiway filtering algorithm to use.void
setOptions(String[] options)
Parses the options for this object.protected weka.core.Instances
tensorToInstances(nz.ac.waikato.cms.adams.multiway.data.tensor.Tensor tensor)
Creates a dataset from the given tensor.-
Methods inherited from class weka.filters.SimpleBatchFilter
batchFinished, hasImmediateOutputFormat, input, input
-
Methods inherited from class weka.filters.Filter
batchFilterFile, bufferInput, copyValues, copyValues, debugTipText, doNotCheckCapabilitiesTipText, filterFile, flushInput, getCapabilities, getCapabilities, getCopyOfInputFormat, getDebug, getDoNotCheckCapabilities, getInputFormat, getOutputFormat, getRevision, initInputLocators, initOutputLocators, inputFormatPeek, isFirstBatchDone, isNewBatch, isOutputFormatDefined, main, makeCopies, makeCopy, mayRemoveInstanceAfterFirstBatchDone, numPendingOutput, output, outputFormatPeek, outputPeek, postExecution, preExecution, push, push, resetQueue, run, runFilter, setDebug, setDoNotCheckCapabilities, setOutputFormat, testInputFormat, toString, useFilter, wekaStaticWrapper
-
-
-
-
Field Detail
-
m_Filter
protected nz.ac.waikato.cms.adams.multiway.algorithm.api.AbstractAlgorithm m_Filter
The multiway filtering algorithm.
-
m_ClassSplitter
protected adams.data.weka.datasetsplitter.ColumnSplitter m_ClassSplitter
Splitter for removing class attribute for supervised filters.
-
m_FilteredTemplate
protected weka.core.Instances m_FilteredTemplate
Template dataset for the filtered output.
-
m_ClassMerger
protected adams.flow.transformer.wekadatasetsmerge.Simple m_ClassMerger
Merger for rejoining class attribute for supervised filters.
-
-
Method Detail
-
listOptions
public Enumeration<weka.core.Option> listOptions()
Gets an enumeration describing the available options.- Specified by:
listOptions
in interfaceweka.core.OptionHandler
- Overrides:
listOptions
in classweka.filters.Filter
- Returns:
- an enumeration of all the available options.
-
getOptions
public String[] getOptions()
returns the options of the current setup- Specified by:
getOptions
in interfaceweka.core.OptionHandler
- Overrides:
getOptions
in classweka.filters.Filter
- Returns:
- the current options
-
setOptions
public void setOptions(String[] options) throws Exception
Parses the options for this object.- Specified by:
setOptions
in interfaceweka.core.OptionHandler
- Overrides:
setOptions
in classweka.filters.Filter
- Parameters:
options
- the options to use- Throws:
Exception
- if the option setting fails
-
getDefaultFilter
public nz.ac.waikato.cms.adams.multiway.algorithm.api.AbstractAlgorithm getDefaultFilter()
Gets the default multiway filtering algorithm to use.- Returns:
- The default filtering algorithm.
-
setFilter
public void setFilter(nz.ac.waikato.cms.adams.multiway.algorithm.api.AbstractAlgorithm value)
Sets the multiway filtering algorithm to use.- Parameters:
value
- The filtering algorithm.
-
getFilter
public nz.ac.waikato.cms.adams.multiway.algorithm.api.AbstractAlgorithm getFilter()
Gets the multiway filtering algorithm to use.- Returns:
- The filtering algorithm.
-
filterTipText
public String filterTipText()
Gets the tip-text for the filter option.- Returns:
- The tip-text as a string.
-
globalInfo
public String globalInfo()
Returns a string describing this filter.- Specified by:
globalInfo
in classweka.filters.SimpleFilter
- Returns:
- a description of the filter suitable for displaying in the explorer/experimenter gui
-
getFilterAsFilter
protected nz.ac.waikato.cms.adams.multiway.algorithm.api.Filter getFilterAsFilter()
Gets the filtering algorithm already cast to a Filter.- Returns:
- The filtering algorithm cast to a Filter.
-
allowAccessToFullInputFormat
public boolean allowAccessToFullInputFormat()
Returns whether to allow the determineOutputFormat(Instances) method access to the full dataset rather than just the header. Default implementation returns false.- Overrides:
allowAccessToFullInputFormat
in classweka.filters.SimpleBatchFilter
- Returns:
- whether determineOutputFormat has access to the full input dataset
-
reset
protected void reset()
resets the filter, i.e., m_NewBatch to true and m_FirstBatchDone to false.- Overrides:
reset
in classweka.filters.SimpleFilter
- See Also:
Filter.m_NewBatch
,Filter.m_FirstBatchDone
-
determineOutputFormat
protected weka.core.Instances determineOutputFormat(weka.core.Instances inputFormat) throws Exception
Determines 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:
determineOutputFormat
in 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 Exception
Processes the given data (may change the provided dataset) and returns the modified version. This method is called in batchFinished().- Specified by:
process
in 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()
-
remergeClassAttribute
protected weka.core.Instances remergeClassAttribute(weka.core.Instances filtered, weka.core.Instances classSet)
Remerges the class attribute with the filtered data for supervised filters.- Parameters:
filtered
- The filtered dataset.classSet
- The class attribute dataset.- Returns:
- The merged dataset.
-
instancesToTensor
protected nz.ac.waikato.cms.adams.multiway.data.tensor.Tensor instancesToTensor(weka.core.Instances instances)
Creates a tensor representation of the given dataset.- Parameters:
instances
- The dataset to convert.- Returns:
- The tensor representation.
-
tensorToInstances
protected weka.core.Instances tensorToInstances(nz.ac.waikato.cms.adams.multiway.data.tensor.Tensor tensor)
Creates a dataset from the given tensor.- Parameters:
tensor
- The tensor to convert.- Returns:
- The dataset representation of the tensor.
-
emptyInstancesForTensor
protected weka.core.Instances emptyInstancesForTensor(int size)
Creates an empty dataset sized to match the given tensor size.- Parameters:
size
- The size of the tensor being converted.- Returns:
- The empty dataset.
-
-