Class NominalToBinary
java.lang.Object
weka.filters.Filter
weka.filters.supervised.attribute.NominalToBinary
- All Implemented Interfaces:
Serializable,CapabilitiesHandler,OptionHandler,RevisionHandler,TechnicalInformationHandler,SupervisedFilter
public class NominalToBinary
extends Filter
implements SupervisedFilter, OptionHandler, TechnicalInformationHandler
Converts all nominal attributes into binary numeric attributes. An attribute with k values is transformed into k binary attributes if the class is nominal (using the one-attribute-per-value approach). Binary attributes are left binary, if option '-A' is not given.If the class is numeric, k - 1 new binary attributes are generated in the manner described in "Classification and Regression Trees" by Breiman et al. (i.e. taking the average class value associated with each attribute value into account)
For more information, see:
L. Breiman, J.H. Friedman, R.A. Olshen, C.J. Stone (1984). Classification and Regression Trees. Wadsworth Inc. BibTeX:
For more information, see:
L. Breiman, J.H. Friedman, R.A. Olshen, C.J. Stone (1984). Classification and Regression Trees. Wadsworth Inc. BibTeX:
@book{Breiman1984,
author = {L. Breiman and J.H. Friedman and R.A. Olshen and C.J. Stone},
publisher = {Wadsworth Inc},
title = {Classification and Regression Trees},
year = {1984},
ISBN = {0412048418}
}
Valid options are:
-N Sets if binary attributes are to be coded as nominal ones.
-A For each nominal value a new attribute is created, not only if there are more than 2 values.
- Version:
- $Revision: 8094 $
- Author:
- Eibe Frank (eibe@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 propertybooleanGets if binary attributes are to be treated as nominal ones.Returns the Capabilities of this filter.String[]Gets the current settings of the filter.Returns the revision string.Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.booleanGets if all nominal values are turned into new attributes, not only if there are more than 2.Returns a string describing this filterbooleanInput an instance for filtering.Returns an enumeration describing the available options.static voidMain method for testing this class.voidsetBinaryAttributesNominal(boolean bool) Sets if binary attributes are to be treates as nominal ones.booleansetInputFormat(Instances instanceInfo) Sets the format of the input instances.voidsetOptions(String[] options) Parses a given list of options.voidsetTransformAllValues(boolean bool) Sets whether all nominal values are transformed into new attributes, not just if there are more than 2.Returns the tip text for this propertyMethods inherited from class weka.filters.Filter
batchFilterFile, filterFile, getCapabilities, getOutputFormat, isFirstBatchDone, isNewBatch, isOutputFormatDefined, makeCopies, makeCopy, numPendingOutput, output, outputPeek, toString, useFilter, wekaStaticWrapper
-
Constructor Details
-
NominalToBinary
public NominalToBinary()
-
-
Method Details
-
globalInfo
Returns a string describing this filter- Returns:
- a description of the filter suitable for displaying in the explorer/experimenter gui
-
getTechnicalInformation
Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.- Specified by:
getTechnicalInformationin interfaceTechnicalInformationHandler- Returns:
- the technical information about this class
-
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 input format can't be set successfully
-
input
Input an instance for filtering. Filter requires all training instances be read before producing output.- Overrides:
inputin classFilter- Parameters:
instance- the input instance- Returns:
- true if the filtered instance may now be collected with output().
- Throws:
IllegalStateException- if no input format has been set
-
batchFinished
public boolean batchFinished()Signify that this batch of input to the filter is finished. If the filter requires all instances prior to filtering, output() may now be called to retrieve the filtered instances.- Overrides:
batchFinishedin classFilter- Returns:
- true if there are instances pending output
- Throws:
IllegalStateException- if no input structure has been defined
-
listOptions
Returns an enumeration describing the available options.- Specified by:
listOptionsin interfaceOptionHandler- Returns:
- an enumeration of all the available options.
-
setOptions
Parses a given list of options. Valid options are:-N Sets if binary attributes are to be coded as nominal ones.
-A For each nominal value a new attribute is created, not only if there are more than 2 values.
- Specified by:
setOptionsin interfaceOptionHandler- 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- Returns:
- an array of strings suitable for passing to setOptions
-
binaryAttributesNominalTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getBinaryAttributesNominal
public boolean getBinaryAttributesNominal()Gets if binary attributes are to be treated as nominal ones.- Returns:
- true if binary attributes are to be treated as nominal ones
-
setBinaryAttributesNominal
public void setBinaryAttributesNominal(boolean bool) Sets if binary attributes are to be treates as nominal ones.- Parameters:
bool- true if binary attributes are to be treated as nominal ones
-
transformAllValuesTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getTransformAllValues
public boolean getTransformAllValues()Gets if all nominal values are turned into new attributes, not only if there are more than 2.- Returns:
- true all nominal values are transformed into new attributes
-
setTransformAllValues
public void setTransformAllValues(boolean bool) Sets whether all nominal values are transformed into new attributes, not just if there are more than 2.- Parameters:
bool- true if all nominal value are transformed into new attributes
-
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
-