Class DatasetLabeler
- java.lang.Object
-
- weka.filters.Filter
-
- weka.filters.SimpleFilter
-
- weka.filters.SimpleBatchFilter
-
- weka.filters.unsupervised.instance.AbstractRowFinderApplier
-
- weka.filters.unsupervised.instance.DatasetLabeler
-
- All Implemented Interfaces:
Serializable
,weka.core.CapabilitiesHandler
,weka.core.CapabilitiesIgnorer
,weka.core.CommandlineRunnable
,weka.core.OptionHandler
,weka.core.RevisionHandler
public class DatasetLabeler extends AbstractRowFinderApplier
Adds an additional attribute to the dataset containing a label whether it was a match or not, i.e., whether the row finder selected a particular row or not.
Valid options are:
-D Turns on output of debugging information.
-W <row finder specification> Full class name of row finder to use, followed by scheme options. eg: "adams.data.weka.rowfinder.NullFinder -D 1" (default: adams.data.weka.rowfinder.NullFinder)
-invert Whether to invert the found row indices. (default: off)
-name <name> Name of the label attribute. (default: 'Label')
-match <label> The label for matching rows. (default: 'yes')
-non-match <label> The label for non-matching rows. (default: 'no')
- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_NAME
the default name of the attribute.static String
LABEL_MATCH
the default label for a "match".static String
LABEL_NONMATCH
the default label for a "non-match".protected weka.filters.unsupervised.attribute.Add
m_AddFilter
the filter for adding the label attribute.protected String
m_AttributeName
the name of the attribute name to add.protected String
m_LabelMatch
the label to use for a match.protected String
m_LabelNonMatch
the label to use for a nonmatch.-
Fields inherited from class weka.filters.unsupervised.instance.AbstractRowFinderApplier
m_Invert, m_OnlyFirstBatch, m_RowFinder
-
-
Constructor Summary
Constructors Constructor Description DatasetLabeler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected weka.core.Instances
apply(weka.core.Instances data, int[] indices)
Applies the indices to the data.String
attributeNameTipText()
Returns the tip text for this property.protected weka.core.Instances
determineOutputFormat(weka.core.Instances inputFormat)
Determines the output format based on the input format and returns this.String
getAttributeName()
Get the name of the attribute to be created.String
getLabelMatch()
Returns the label for the matching rows.String
getLabelNonMatch()
Returns the label for the non-matching rows.String[]
getOptions()
Gets the current settings of the classifier.String
getRevision()
Returns the revision string.String
globalInfo()
Returns a string describing this classifier.String
labelMatchTipText()
Returns the tip text for this property.String
labelNonMatchTipText()
Returns the tip text for this property.Enumeration
listOptions()
Returns an enumeration describing the available options.protected boolean
mayRemoveInstances()
Method that returns whether the filter may remove instances after the first batch has been done.String
rowFinderTipText()
Returns the tip text for this property.void
setAttributeName(String name)
Set the new attribute's name.void
setLabelMatch(String value)
Sets the label for the matching rows.void
setLabelNonMatch(String value)
Sets the label for the non-matching rows.void
setOptions(String[] options)
Parses the options for this object.-
Methods inherited from class weka.filters.unsupervised.instance.AbstractRowFinderApplier
getCapabilities, getInvert, getOnlyFirstBatch, getRowFinder, invertTipText, mayRemoveInstanceAfterFirstBatchDone, onlyFirstBatchTipText, process, setInvert, setOnlyFirstBatch, setRowFinder
-
Methods inherited from class weka.filters.SimpleBatchFilter
allowAccessToFullInputFormat, batchFinished, hasImmediateOutputFormat, input
-
Methods inherited from class weka.filters.Filter
batchFilterFile, bufferInput, copyValues, copyValues, debugTipText, doNotCheckCapabilitiesTipText, filterFile, flushInput, getCapabilities, getDebug, getDoNotCheckCapabilities, getInputFormat, getOutputFormat, initInputLocators, initOutputLocators, inputFormatPeek, isFirstBatchDone, isNewBatch, isOutputFormatDefined, main, makeCopies, makeCopy, numPendingOutput, output, outputFormatPeek, outputPeek, postExecution, preExecution, push, push, resetQueue, run, runFilter, setDebug, setDoNotCheckCapabilities, setOutputFormat, testInputFormat, toString, useFilter, wekaStaticWrapper
-
-
-
-
Field Detail
-
LABEL_MATCH
public static final String LABEL_MATCH
the default label for a "match".- See Also:
- Constant Field Values
-
LABEL_NONMATCH
public static final String LABEL_NONMATCH
the default label for a "non-match".- See Also:
- Constant Field Values
-
DEFAULT_NAME
public static final String DEFAULT_NAME
the default name of the attribute.- See Also:
- Constant Field Values
-
m_AttributeName
protected String m_AttributeName
the name of the attribute name to add.
-
m_LabelMatch
protected String m_LabelMatch
the label to use for a match.
-
m_LabelNonMatch
protected String m_LabelNonMatch
the label to use for a nonmatch.
-
m_AddFilter
protected weka.filters.unsupervised.attribute.Add m_AddFilter
the filter for adding the label attribute.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing this classifier.- Specified by:
globalInfo
in classweka.filters.SimpleFilter
- Returns:
- a description of the classifier suitable for displaying in the explorer/experimenter gui
-
listOptions
public Enumeration listOptions()
Returns an enumeration describing the available options.- Specified by:
listOptions
in interfaceweka.core.OptionHandler
- Overrides:
listOptions
in classAbstractRowFinderApplier
- Returns:
- an enumeration of all the available options.
-
setOptions
public void setOptions(String[] options) throws Exception
Parses the options for this object.- Specified by:
setOptions
in interfaceweka.core.OptionHandler
- Overrides:
setOptions
in classAbstractRowFinderApplier
- Parameters:
options
- the options to use- Throws:
Exception
- if setting of options fails
-
getOptions
public String[] getOptions()
Gets the current settings of the classifier.- Specified by:
getOptions
in interfaceweka.core.OptionHandler
- Overrides:
getOptions
in classAbstractRowFinderApplier
- Returns:
- an array of strings suitable for passing to setOptions
-
rowFinderTipText
public String rowFinderTipText()
Returns the tip text for this property.- Specified by:
rowFinderTipText
in classAbstractRowFinderApplier
- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setAttributeName
public void setAttributeName(String name)
Set the new attribute's name.- Parameters:
name
- the new name
-
getAttributeName
public String getAttributeName()
Get the name of the attribute to be created.- Returns:
- the new attribute name
-
attributeNameTipText
public String attributeNameTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setLabelMatch
public void setLabelMatch(String value)
Sets the label for the matching rows.- Parameters:
name
- the label
-
getLabelMatch
public String getLabelMatch()
Returns the label for the matching rows.- Returns:
- the label
-
labelMatchTipText
public String labelMatchTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setLabelNonMatch
public void setLabelNonMatch(String value)
Sets the label for the non-matching rows.- Parameters:
name
- the label
-
getLabelNonMatch
public String getLabelNonMatch()
Returns the label for the non-matching rows.- Returns:
- the label
-
labelNonMatchTipText
public String labelNonMatchTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
determineOutputFormat
protected weka.core.Instances determineOutputFormat(weka.core.Instances inputFormat) throws Exception
Determines 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:
determineOutputFormat
in classAbstractRowFinderApplier
- Parameters:
inputFormat
- the input format to base the output format on- Returns:
- the output format
- Throws:
Exception
- in case the determination goes wrong
-
mayRemoveInstances
protected boolean mayRemoveInstances()
Method that returns whether the filter may remove instances after the first batch has been done.- Specified by:
mayRemoveInstances
in classAbstractRowFinderApplier
- Returns:
- always true
- See Also:
AbstractRowFinderApplier.mayRemoveInstanceAfterFirstBatchDone()
-
apply
protected weka.core.Instances apply(weka.core.Instances data, int[] indices)
Applies the indices to the data. In case inverting is enabled, the indices have already been inverted.- Specified by:
apply
in classAbstractRowFinderApplier
- Parameters:
data
- the data to processindices
- the indices to use- Returns:
- the processed data
-
getRevision
public String getRevision()
Returns the revision string.- Specified by:
getRevision
in interfaceweka.core.RevisionHandler
- Overrides:
getRevision
in classweka.filters.Filter
- Returns:
- the revision
-
-