Package weka.filters.supervised.instance
Class ClassBalancer
java.lang.Object
weka.filters.Filter
weka.filters.SimpleFilter
weka.filters.SimpleBatchFilter
weka.filters.supervised.instance.ClassBalancer
- All Implemented Interfaces:
Serializable
,CapabilitiesHandler
,CapabilitiesIgnorer
,CommandlineRunnable
,OptionHandler
,RevisionHandler
,WeightedAttributesHandler
,WeightedInstancesHandler
,SupervisedFilter
public class ClassBalancer
extends SimpleBatchFilter
implements SupervisedFilter, WeightedInstancesHandler, WeightedAttributesHandler
Reweights the instances in the data so that each class has the same total weight. The total sum of weights accross all instances will be maintained. Only the weights in the first batch of data received by this filter are changed, so it can be used with the FilteredClassifier. If the class is numeric, it is discretized using equal-width discretization to establish pseudo classes for weighting.
Valid options are:
-num-intervals <positive integer> The number of discretization intervals to use when the class is numeric (default of weka.attribute.unsupervised.Discretize).
-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 when input format is set (use with caution).
- Version:
- $Revision: 10215 $
- Author:
- Eibe Frank
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the Capabilities of this filter.int
Gets the number of discretization intervals to use when the class is numeric.Returns the revision string.Returns a string describing this filter.static void
runs the filter with the given argumentsvoid
setNumIntervals
(int num) Sets the number of discretization intervals to use.Methods inherited from class weka.filters.SimpleBatchFilter
allowAccessToFullInputFormat, 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, getOptions, getOutputFormat, isFirstBatchDone, isNewBatch, isOutputFormatDefined, listOptions, makeCopies, makeCopy, mayRemoveInstanceAfterFirstBatchDone, numPendingOutput, output, outputPeek, postExecution, preExecution, run, runFilter, setDebug, setDoNotCheckCapabilities, setOptions, toString, useFilter, wekaStaticWrapper
-
Constructor Details
-
ClassBalancer
public ClassBalancer()
-
-
Method Details
-
getNumIntervals
@OptionMetadata(displayName="Number of discretization intervals", description="The number of discretization intervals to use when the class is numeric.", displayOrder=1, commandLineParamName="num-intervals", commandLineParamSynopsis="-num-intervals <int>", commandLineParamIsFlag=false) public int getNumIntervals()Gets the number of discretization intervals to use when the class is numeric.- Returns:
- the number of discretization intervals
-
setNumIntervals
public void setNumIntervals(int num) Sets the number of discretization intervals to use.- Parameters:
num
- the number of discretization intervals to use.
-
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
-
getCapabilities
Returns the Capabilities of this filter.- Specified by:
getCapabilities
in interfaceCapabilitiesHandler
- Overrides:
getCapabilities
in classFilter
- Returns:
- the capabilities of this object
- See Also:
-
getRevision
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Overrides:
getRevision
in classFilter
- Returns:
- the revision
-
main
runs the filter with the given arguments- Parameters:
args
- the commandline arguments
-