Class RemoveMisclassified
java.lang.Object
weka.filters.Filter
weka.filters.unsupervised.instance.RemoveMisclassified
- All Implemented Interfaces:
Serializable,CapabilitiesHandler,CapabilitiesIgnorer,CommandlineRunnable,OptionHandler,RevisionHandler,WeightedAttributesHandler,WeightedInstancesHandler,UnsupervisedFilter
public class RemoveMisclassified
extends Filter
implements UnsupervisedFilter, OptionHandler, WeightedAttributesHandler, WeightedInstancesHandler
A filter that removes instances which are
incorrectly classified. Useful for removing outliers.
Valid options are:
-W <classifier specification> Full class name of classifier to use, followed by scheme options. eg: "weka.classifiers.bayes.NaiveBayes -D" (default: weka.classifiers.rules.ZeroR)
-C <class index> Attribute on which misclassifications are based. If < 0 will use any current set class or default to the last attribute.
-F <number of folds> The number of folds to use for cross-validation cleansing. (<2 = no cross-validation - default).
-T <threshold> Threshold for the max error when predicting numeric class. (Value should be >= 0, default = 0.1).
-I The maximum number of cleansing iterations to perform. (<1 = until fully cleansed - default)
-V Invert the match so that correctly classified instances are discarded.
- Version:
- $Revision: 14534 $
- Author:
- Richard Kirkby (rkirkby@cs.waikato.ac.nz), Malcolm Ware (mfw4@cs.waikato.ac.nz)
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanSignify that this batch of input to the filter is finished.Returns the tip text for this propertyReturns the tip text for this propertyReturns the Capabilities of this filter.Gets the classifier used by the filter.intGets the attribute on which misclassifications are based.booleanGet whether selection is inverted.intGets the maximum number of cleansing iterations performedintGets the number of cross-validation folds used by the filter.String[]Gets the current settings of the filter.Returns the revision string.doubleGets the threshold for the max error when predicting a numeric class.Returns a string describing this filterbooleanInput an instance for filtering.Returns the tip text for this propertyReturns an enumeration describing the available options.static voidMain method for testing this class.Returns the tip text for this propertyReturns the tip text for this propertyvoidsetClassifier(Classifier classifier) Sets the classifier to classify instances with.voidsetClassIndex(int classIndex) Sets the attribute on which misclassifications are based.booleansetInputFormat(Instances instanceInfo) Sets the format of the input instances.voidsetInvert(boolean invert) Set whether selection is inverted.voidsetMaxIterations(int iterations) Sets the maximum number of cleansing iterations to perform - < 1 means go until fully cleansedvoidsetNumFolds(int numOfFolds) Sets the number of cross-validation folds to use - < 2 means no cross-validation.voidsetOptions(String[] options) Parses a given list of options.voidsetThreshold(double threshold) Sets the threshold for the max error when predicting a numeric class.Returns the tip text for this propertyMethods 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
-
RemoveMisclassified
public RemoveMisclassified()
-
-
Method Details
-
getCapabilities
Returns the Capabilities of this filter.- Specified by:
getCapabilitiesin interfaceCapabilitiesHandler- Overrides:
getCapabilitiesin classFilter- Returns:
- the capabilities of this object
- See Also:
-
setInputFormat
Sets the format of the input instances.- Overrides:
setInputFormatin classFilter- Parameters:
instanceInfo- an Instances object containing the input instance structure (any instances contained in the object are ignored - only the structure is required).- Returns:
- true if the outputFormat may be collected immediately
- Throws:
Exception- if the inputFormat can't be set successfully
-
input
Input an instance for filtering.- Overrides:
inputin classFilter- Parameters:
instance- the input instance- Returns:
- true if the filtered instance may now be collected with output().
- Throws:
NullPointerException- if the input format has not been defined.Exception- if the input instance was not of the correct format or if there was a problem with the filtering.
-
batchFinished
Signify that this batch of input to the filter is finished.- Overrides:
batchFinishedin classFilter- Returns:
- true if there are instances pending output
- Throws:
IllegalStateException- if no input structure has been definedNullPointerException- if no input structure has been defined,Exception- if there was a problem finishing the batch.
-
listOptions
Returns an enumeration describing the available options.- Specified by:
listOptionsin interfaceOptionHandler- Overrides:
listOptionsin classFilter- Returns:
- an enumeration of all the available options.
-
setOptions
Parses a given list of options. Valid options are:-W <classifier specification> Full class name of classifier to use, followed by scheme options. eg: "weka.classifiers.bayes.NaiveBayes -D" (default: weka.classifiers.rules.ZeroR)
-C <class index> Attribute on which misclassifications are based. If < 0 will use any current set class or default to the last attribute.
-F <number of folds> The number of folds to use for cross-validation cleansing. (<2 = no cross-validation - default).
-T <threshold> Threshold for the max error when predicting numeric class. (Value should be >= 0, default = 0.1).
-I The maximum number of cleansing iterations to perform. (<1 = until fully cleansed - default)
-V Invert the match so that correctly classified instances are discarded.
- Specified by:
setOptionsin interfaceOptionHandler- Overrides:
setOptionsin classFilter- Parameters:
options- the list of options as an array of strings- Throws:
Exception- if an option is not supported
-
getOptions
Gets the current settings of the filter.- Specified by:
getOptionsin interfaceOptionHandler- Overrides:
getOptionsin classFilter- Returns:
- an array of strings suitable for passing to setOptions
-
globalInfo
Returns a string describing this filter- Returns:
- a description of the filter suitable for displaying in the explorer/experimenter gui
-
classifierTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setClassifier
Sets the classifier to classify instances with.- Parameters:
classifier- The classifier to be used (with its options set).
-
getClassifier
Gets the classifier used by the filter.- Returns:
- The classifier to be used.
-
classIndexTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setClassIndex
public void setClassIndex(int classIndex) Sets the attribute on which misclassifications are based. If < 0 will use any current set class or default to the last attribute.- Parameters:
classIndex- the class index.
-
getClassIndex
public int getClassIndex()Gets the attribute on which misclassifications are based.- Returns:
- the class index.
-
numFoldsTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setNumFolds
public void setNumFolds(int numOfFolds) Sets the number of cross-validation folds to use - < 2 means no cross-validation.- Parameters:
numOfFolds- the number of folds.
-
getNumFolds
public int getNumFolds()Gets the number of cross-validation folds used by the filter.- Returns:
- the number of folds.
-
thresholdTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setThreshold
public void setThreshold(double threshold) Sets the threshold for the max error when predicting a numeric class. The value should be >= 0.- Parameters:
threshold- the numeric theshold.
-
getThreshold
public double getThreshold()Gets the threshold for the max error when predicting a numeric class.- Returns:
- the numeric threshold.
-
maxIterationsTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setMaxIterations
public void setMaxIterations(int iterations) Sets the maximum number of cleansing iterations to perform - < 1 means go until fully cleansed- Parameters:
iterations- the maximum number of iterations.
-
getMaxIterations
public int getMaxIterations()Gets the maximum number of cleansing iterations performed- Returns:
- the maximum number of iterations.
-
invertTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setInvert
public void setInvert(boolean invert) Set whether selection is inverted.- Parameters:
invert- whether or not to invert selection.
-
getInvert
public boolean getInvert()Get whether selection is inverted.- Returns:
- whether or not selection is inverted.
-
getRevision
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Overrides:
getRevisionin classFilter- Returns:
- the revision
-
main
Main method for testing this class.- Parameters:
argv- should contain arguments to the filter: use -h for help
-