public class NominalToBinaryFilter
extends java.lang.Object
Valid filter-specific options are:
-N
If binary attributes are to be coded as nominal ones.
Modifier and Type | Field and Description |
---|---|
protected boolean |
m_NewBatch
Record whether the filter is at the start of a batch
|
Constructor and Description |
---|
NominalToBinaryFilter() |
Modifier and Type | Method and Description |
---|---|
static void |
batchFilterFile(NominalToBinaryFilter filter,
java.lang.String[] options)
Method for testing filters ability to process multiple batches.
|
boolean |
batchFinished()
Signify that this batch of input to the filter is finished.
|
protected void |
bufferInput(M5Instance instance)
Adds the supplied input instance to the inputformat dataset for
later processing.
|
protected void |
copyStringValues(M5Instance instance,
boolean instSrcCompat,
M5Instances srcDataset,
int[] srcStrAtts,
M5Instances destDataset,
int[] destStrAtts)
Takes string values referenced by an Instance and copies them from a
source dataset to a destination dataset.
|
protected void |
copyStringValues(M5Instance instance,
boolean instSrcCompat,
M5Instances srcDataset,
M5Instances destDataset)
Takes string values referenced by an Instance and copies them from a
source dataset to a destination dataset.
|
static void |
filterFile(NominalToBinaryFilter filter,
java.lang.String[] options)
Method for testing filters.
|
protected void |
flushInput()
This will remove all buffered instances from the inputformat dataset.
|
boolean |
getBinaryAttributesNominal()
Gets if binary attributes are to be treated as nominal ones.
|
protected M5Instances |
getInputFormat()
Gets the currently set inputformat instances.
|
protected int[] |
getInputStringIndex()
Returns an array containing the indices of all string attributes in the
input format.
|
java.lang.String[] |
getOptions()
Gets the current settings of the filter.
|
M5Instances |
getOutputFormat()
Gets the format of the output instances.
|
protected int[] |
getOutputStringIndex()
Returns an array containing the indices of all string attributes in the
output format.
|
protected int[] |
getStringIndices(M5Instances insts)
Gets an array containing the indices of all string attributes.
|
boolean |
input(M5Instance instance)
Input an instance for filtering.
|
boolean |
inputFormat(M5Instances instanceInfo)
Deprecated.
use
setInputFormat(Instances) instead. |
boolean |
isOutputFormatDefined()
Returns whether the output format is ready to be collected
|
java.util.Enumeration |
listOptions()
Returns an enumeration describing the available options
|
int |
numPendingOutput()
Returns the number of instances pending output
|
M5Instance |
output()
Output an instance after filtering and remove from the output queue.
|
M5Instances |
outputFormat()
Deprecated.
use
getOutputFormat() instead. |
protected M5Instances |
outputFormatPeek()
Returns a reference to the current output format without
copying it.
|
M5Instance |
outputPeek()
Output an instance after filtering but do not remove from the
output queue.
|
protected void |
push(M5Instance instance)
Adds an output instance to the queue.
|
protected void |
resetQueue()
Clears the output queue.
|
void |
setBinaryAttributesNominal(boolean bool)
Sets if binary attributes are to be treates as nominal ones.
|
boolean |
setInputFormat(M5Instances instanceInfo)
Sets the format of the input instances.
|
void |
setOptions(java.lang.String[] options)
Parses the options for this object.
|
protected void |
setOutputFormat(M5Instances outputFormat)
Sets the format of output instances.
|
boolean |
superSetInputFormat(M5Instances instanceInfo)
Store the input formats
|
static M5Instances |
useFilter(M5Instances data,
NominalToBinaryFilter filter)
Filters an entire set of instances through a filter and returns
the new set.
|
protected boolean m_NewBatch
protected void setOutputFormat(M5Instances outputFormat)
outputFormat
- the new output formatprotected M5Instances getInputFormat()
protected M5Instances outputFormatPeek()
protected void push(M5Instance instance)
instance
- the instance to be added to the queueprotected void resetQueue()
protected void bufferInput(M5Instance instance)
instance
- the Instance
to buffer.protected int[] getInputStringIndex()
protected int[] getOutputStringIndex()
protected void copyStringValues(M5Instance instance, boolean instSrcCompat, M5Instances srcDataset, M5Instances destDataset)
instance
- the instance containing references to strings in the source
dataset that will have references updated to be valid for the destination
dataset.instSrcCompat
- true if the instance structure is the same as the
source, or false if it is the same as the destinationsrcDataset
- the dataset for which the current instance string
references are valid (after any position mapping if needed)destDataset
- the dataset for which the current instance string
references need to be inserted (after any position mapping if needed)protected void copyStringValues(M5Instance instance, boolean instSrcCompat, M5Instances srcDataset, int[] srcStrAtts, M5Instances destDataset, int[] destStrAtts)
instance
- the instance containing references to strings in the source
dataset that will have references updated to be valid for the destination
dataset.instSrcCompat
- true if the instance structure is the same as the
source, or false if it is the same as the destination (i.e. which of the
string attribute indices contains the correct locations for this instance).srcDataset
- the dataset for which the current instance string
references are valid (after any position mapping if needed)srcStrAtts
- an array containing the indices of string attributes
in the source datset.destDataset
- the dataset for which the current instance string
references need to be inserted (after any position mapping if needed)destStrAtts
- an array containing the indices of string attributes
in the destination datset.protected void flushInput()
public boolean inputFormat(M5Instances instanceInfo) throws java.lang.Exception
setInputFormat(Instances)
instead.instanceInfo
- java.lang.Exception
public final M5Instances outputFormat()
getOutputFormat()
instead.public final M5Instances getOutputFormat()
java.lang.NullPointerException
- if no input structure has been
defined (or the output format hasn't been determined yet)public M5Instance output()
java.lang.NullPointerException
- if no output structure has been definedpublic M5Instance outputPeek()
java.lang.NullPointerException
- if no input structure has been definedpublic int numPendingOutput()
java.lang.NullPointerException
- if no input structure has been definedpublic boolean isOutputFormatDefined()
protected int[] getStringIndices(M5Instances insts)
insts
- the Instances to scan for string attributes.public static M5Instances useFilter(M5Instances data, NominalToBinaryFilter filter) throws java.lang.Exception
data
- the data to be filteredfilter
- the filter to be usedjava.lang.Exception
- if the filter can't be used successfullypublic static void filterFile(NominalToBinaryFilter filter, java.lang.String[] options) throws java.lang.Exception
filter
- filter to transform nominal values into binary.options
- should contain the following arguments: java.lang.Exception
- if something goes wrong or the user requests help on
command optionspublic static void batchFilterFile(NominalToBinaryFilter filter, java.lang.String[] options) throws java.lang.Exception
filter
- filter to transform nominal values into binary.options
- should contain the following arguments:java.lang.Exception
- if something goes wrong or the user requests help on
command optionspublic boolean setInputFormat(M5Instances instanceInfo) throws java.lang.Exception
instanceInfo
- an Instances object containing the input
instance structure (any instances contained in the object are
ignored - only the structure is required).java.lang.Exception
- if the input format can't be set
successfullypublic boolean superSetInputFormat(M5Instances instanceInfo) throws java.lang.Exception
instanceInfo
- input information as Dataset.java.lang.Exception
- if the information can not be extracted.public boolean input(M5Instance instance) throws java.lang.Exception
instance
- the input instancejava.lang.Exception
java.lang.IllegalStateException
- if no input format has been setpublic boolean batchFinished() throws java.lang.Exception
java.lang.Exception
java.lang.IllegalStateException
- if no input structure has been definedpublic java.util.Enumeration listOptions()
public void setOptions(java.lang.String[] options) throws java.lang.Exception
-N
If binary attributes are to be coded as nominal ones.
options
- the list of options as an array of stringsjava.lang.Exception
- if an option is not supportedpublic java.lang.String[] getOptions()
public boolean getBinaryAttributesNominal()
public void setBinaryAttributesNominal(boolean bool)
bool
- true if binary attributes are to be treated as nominal ones