Class RandomSubset
java.lang.Object
weka.filters.Filter
weka.filters.SimpleFilter
weka.filters.SimpleBatchFilter
weka.filters.unsupervised.attribute.RandomSubset
- All Implemented Interfaces:
Serializable
,CapabilitiesHandler
,CapabilitiesIgnorer
,CommandlineRunnable
,OptionHandler
,Randomizable
,RevisionHandler
,WeightedAttributesHandler
,WeightedInstancesHandler
public class RandomSubset
extends SimpleBatchFilter
implements Randomizable, WeightedInstancesHandler, WeightedAttributesHandler
Chooses a random subset of non-class attributes, either an absolute number or a percentage. Attributes are included
in the order in which they occur in the input data. The class attribute (if present) is always included in the output.
Valid options are:
-N <double> The number of attributes to randomly select. If < 1 then percentage, >= 1 absolute number. (default: 0.5)
-V Invert selection - i.e. randomly remove rather than select.
-S <int> The seed value. (default: 1)
-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: 15073 $
- Author:
- fracpete (fracpete at waikato dot ac dot nz), eibe@cs.waikato.ac.nz
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns whether to allow the determineOutputFormat(Instances) method access to the full dataset rather than just the header.Returns the Capabilities of this filter.boolean
Get whether to invert the selection - i.e.double
Get the number of attributes (< 1 percentage, >= 1 absolute number).String[]
Gets the current settings of the filter.Returns the revision string.int
getSeed()
Get the seed value for the random number generator.Returns a string describing this filter.Returns the tip text for this property.Returns an enumeration describing the available options.static void
Runs the filter with the given parameters.Returns the tip text for this property.Returns the tip text for this property.void
setInvertSelection
(boolean inv) Set whether to invert the selection - i.e.void
setNumAttributes
(double value) Set the number of attributes.void
setOptions
(String[] options) Parses a given list of options.void
setSeed
(int value) Set the seed value for the random number generator.Methods inherited from class weka.filters.SimpleBatchFilter
batchFinished, input, input
Methods inherited from class weka.filters.SimpleFilter
setInputFormat
Methods inherited from class weka.filters.Filter
batchFilterFile, debugTipText, doNotCheckCapabilitiesTipText, filterFile, getCapabilities, getCopyOfInputFormat, getDebug, getDoNotCheckCapabilities, getOutputFormat, isFirstBatchDone, isNewBatch, isOutputFormatDefined, makeCopies, makeCopy, mayRemoveInstanceAfterFirstBatchDone, numPendingOutput, output, outputPeek, postExecution, preExecution, run, runFilter, setDebug, setDoNotCheckCapabilities, toString, useFilter, wekaStaticWrapper
-
Constructor Details
-
RandomSubset
public RandomSubset()
-
-
Method Details
-
globalInfo
Returns a string describing this filter.- Specified by:
globalInfo
in classSimpleFilter
- Returns:
- a description of the filter suitable for displaying in the explorer/experimenter gui
-
listOptions
Returns an enumeration describing the available options.- Specified by:
listOptions
in interfaceOptionHandler
- Overrides:
listOptions
in classFilter
- Returns:
- an enumeration of all the available options.
-
getOptions
Gets the current settings of the filter.- Specified by:
getOptions
in interfaceOptionHandler
- Overrides:
getOptions
in classFilter
- Returns:
- an array of strings suitable for passing to setOptions
-
setOptions
Parses a given list of options. Valid options are:-N <double> The number of attributes to randomly select. If < 1 then percentage, >= 1 absolute number. (default: 0.5)
-V Invert selection - i.e. randomly remove rather than select.
-S <int> The seed value. (default: 1)
-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).
- Specified by:
setOptions
in interfaceOptionHandler
- Overrides:
setOptions
in classFilter
- Parameters:
options
- the list of options as an array of strings- Throws:
Exception
- if an option is not supported
-
numAttributesTipText
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getNumAttributes
public double getNumAttributes()Get the number of attributes (< 1 percentage, >= 1 absolute number).- Returns:
- the number of attributes.
-
setNumAttributes
public void setNumAttributes(double value) Set the number of attributes.- Parameters:
value
- the number of attributes to use.
-
invertSelectionTipText
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 inv) Set whether to invert the selection - i.e. randomly remove rather than select attributes.- Parameters:
inv
- true if the selection should be inverted
-
getInvertSelection
public boolean getInvertSelection()Get whether to invert the selection - i.e. randomly remove rather than select attributes.- Returns:
- true if the selection should be inverted
-
seedTipText
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getSeed
public int getSeed()Get the seed value for the random number generator.- Specified by:
getSeed
in interfaceRandomizable
- Returns:
- the seed value.
-
setSeed
public void setSeed(int value) Set the seed value for the random number generator.- Specified by:
setSeed
in interfaceRandomizable
- Parameters:
value
- the seed value.
-
getCapabilities
Returns the Capabilities of this filter.- Specified by:
getCapabilities
in interfaceCapabilitiesHandler
- Overrides:
getCapabilities
in classFilter
- Returns:
- the capabilities of this object
- See Also:
-
allowAccessToFullInputFormat
public boolean allowAccessToFullInputFormat()Returns whether to allow the determineOutputFormat(Instances) method access to the full dataset rather than just the header.- Overrides:
allowAccessToFullInputFormat
in classSimpleBatchFilter
- Returns:
- true for this filter so that input data can affect subset of attributes that is selected
-
getRevision
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Overrides:
getRevision
in classFilter
- Returns:
- the revision
-
main
Runs the filter with the given parameters. Use -h to list options.- Parameters:
args
- the commandline options
-