Class KennardStone
- java.lang.Object
-
- weka.filters.Filter
-
- weka.filters.SimpleFilter
-
- weka.filters.SimpleBatchFilter
-
- weka.filters.unsupervised.instance.KennardStone
-
- All Implemented Interfaces:
Serializable,weka.core.CapabilitiesHandler,weka.core.CapabilitiesIgnorer,weka.core.CommandlineRunnable,weka.core.OptionHandler,weka.core.RevisionHandler
public class KennardStone extends weka.filters.SimpleBatchFilterApplies the Kennard-Stone algorithm to the dataset.
Each row has the pre-filter (eg PLS) applied before performing the search. The rows selected by the algorithm are returned in the original space, however.
Distance calculation only uses numeric attributes in the defined range.
Valid options are:-number-in-subset <value> Number of rows in subset. (default: -1)
-pre-filter <value> Pre-filter to apply to the data to perform the search on. (default: weka.filters.unsupervised.attribute.SavitzkyGolay -left 3 -right 3 -polynomial 2 -derivative 1)
-att-range <value> The attribute range to limit distance calculation to (after applying pre-filter). (default: first-last)
-V Whether to invert the selection.
-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).
- Version:
- $Revision$
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringATT_RANGEstatic RangeDEFAULT_ATT_RANGEstatic intDEFAULT_NUMBER_IN_SUBSETstatic weka.filters.FilterDEFAULT_PRE_FILTERprotected static StringINVERT_SELECTIONprotected Rangem_AttRangethe range of attributes to apply to.protected booleanm_InvertSelectionwhether to invert the selection.protected intm_NumberInSubsetNumber of spectra to select in subsetprotected weka.filters.Filterm_PreFilterPre filter to apply before selectionprotected static StringNUMBER_IN_SUBSETprotected static StringPRE_FILTER
-
Constructor Summary
Constructors Constructor Description KennardStone()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringattRangeTipText()Returns the tip text for this property.protected doublecalculateDistance(weka.core.Instance inst1, weka.core.Instance inst2)Calculate the distance between any two instances.protected weka.core.InstancesdetermineOutputFormat(weka.core.Instances inputFormat)Determines the output format based on the input format and returns this.RangegetAttRange()Returns the attribute range to use for distance calculation (after applying pre-filter).weka.core.CapabilitiesgetCapabilities()Returns the Capabilities of this filter.booleangetInvertSelection()Gets if selection is to be inverted.intgetNumberInSubset()Returns the number of rows to select in subset.String[]getOptions()Gets the current settings of the classifier.weka.filters.FiltergetPreFilter()Returns the pre-filter to apply to the data to perform the search on.StringglobalInfo()Returns a string describing this filter.StringinvertSelectionTipText()Returns the tip text for this property.EnumerationlistOptions()Returns an enumeration describing the available options.StringnumberInSubsetTipText()Returns the tip text for this property.StringpreFilterTipText()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.voidsetAttRange(Range value)Sets the attribute range to use for distance calculation (after applying pre-filter).voidsetInvertSelection(boolean value)Sets if selection is to be inverted.voidsetNumberInSubset(int value)Sets the number of rws to select in subset.voidsetOptions(String[] options)Parses a given list of options.voidsetPreFilter(weka.filters.Filter value)Sets the pre-filter to apply to the data to perform the search on.-
Methods inherited from class weka.filters.SimpleBatchFilter
allowAccessToFullInputFormat, batchFinished, hasImmediateOutputFormat, input, input
-
Methods inherited from class weka.filters.Filter
batchFilterFile, bufferInput, copyValues, copyValues, debugTipText, doNotCheckCapabilitiesTipText, filterFile, flushInput, 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
-
NUMBER_IN_SUBSET
protected static String NUMBER_IN_SUBSET
-
PRE_FILTER
protected static String PRE_FILTER
-
ATT_RANGE
protected static String ATT_RANGE
-
INVERT_SELECTION
protected static String INVERT_SELECTION
-
DEFAULT_NUMBER_IN_SUBSET
public static final int DEFAULT_NUMBER_IN_SUBSET
- See Also:
- Constant Field Values
-
DEFAULT_PRE_FILTER
public static final weka.filters.Filter DEFAULT_PRE_FILTER
-
DEFAULT_ATT_RANGE
public static final Range DEFAULT_ATT_RANGE
-
m_NumberInSubset
protected int m_NumberInSubset
Number of spectra to select in subset
-
m_PreFilter
protected weka.filters.Filter m_PreFilter
Pre filter to apply before selection
-
m_AttRange
protected Range m_AttRange
the range of attributes to apply to.
-
m_InvertSelection
protected boolean m_InvertSelection
whether to invert the selection.
-
-
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 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 given list of options.- 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 classifier.- Specified by:
getOptionsin interfaceweka.core.OptionHandler- Overrides:
getOptionsin classweka.filters.Filter- Returns:
- an array of strings suitable for passing to setOptions
-
setNumberInSubset
public void setNumberInSubset(int value)
Sets the number of rws to select in subset.- Parameters:
value- the number
-
getNumberInSubset
public int getNumberInSubset()
Returns the number of rows to select in subset.- Returns:
- the number
-
numberInSubsetTipText
public String numberInSubsetTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setPreFilter
public void setPreFilter(weka.filters.Filter value)
Sets the pre-filter to apply to the data to perform the search on.- Parameters:
value- the filter
-
getPreFilter
public weka.filters.Filter getPreFilter()
Returns the pre-filter to apply to the data to perform the search on.- Returns:
- the filter
-
preFilterTipText
public String preFilterTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setAttRange
public void setAttRange(Range value)
Sets the attribute range to use for distance calculation (after applying pre-filter).- Parameters:
value- the range
-
getAttRange
public Range getAttRange()
Returns the attribute range to use for distance calculation (after applying pre-filter).- Returns:
- the range
-
attRangeTipText
public String attRangeTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setInvertSelection
public void setInvertSelection(boolean value)
Sets if selection is to be inverted.- Parameters:
value- true if inversion is to be performed
-
getInvertSelection
public boolean getInvertSelection()
Gets if selection is to be inverted.- Returns:
- true if the selection is to be inverted
-
invertSelectionTipText
public String invertSelectionTipText()
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
-
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
-
calculateDistance
protected double calculateDistance(weka.core.Instance inst1, weka.core.Instance inst2)Calculate the distance between any two instances. Currently just uses euclidean distance.- Parameters:
inst1- Instance1inst2- Instance2- Returns:
- the distance
-
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
-
-