Class ReplaceMissingWithUserConstant
java.lang.Object
weka.filters.Filter
weka.filters.unsupervised.attribute.PotentialClassIgnorer
weka.filters.unsupervised.attribute.ReplaceMissingWithUserConstant
- All Implemented Interfaces:
Serializable
,CapabilitiesHandler
,CapabilitiesIgnorer
,CommandlineRunnable
,EnvironmentHandler
,OptionHandler
,RevisionHandler
,WeightedAttributesHandler
,WeightedInstancesHandler
,StreamableFilter
,UnsupervisedFilter
public class ReplaceMissingWithUserConstant
extends PotentialClassIgnorer
implements UnsupervisedFilter, StreamableFilter, EnvironmentHandler, WeightedInstancesHandler, WeightedAttributesHandler
Replaces all missing values for nominal, string,
numeric and date attributes in the dataset with user-supplied constant
values.
- Version:
- $Revision: 14508 $
- Author:
- Mark Hall (mhall{[at]}pentaho{[dot]}com)
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionTip text for this property suitable for displaying in the GUI.Tip text for this property suitable for displaying in the GUI.Tip text for this property suitable for displaying in the GUI.Get the list of attributes to consider for replacing missing valuesReturns the Capabilities of this filter.Get the date format to use for parsing the date replacement constantGet the date replacement valueGet the nominal/string replacement valueGet the numeric replacement valueString[]
Gets the current settings of the filter.Returns the revision string.Returns a string describing this filterboolean
Input an instance for filtering.Returns an enumeration describing the available options.static void
Main method for testing this class.Tip text for this property suitable for displaying in the GUI.Tip text for this property suitable for displaying in the GUI.void
setAttributes
(String range) Set the list of attributes to consider for replacing missing valuesvoid
setDateFormat
(String dateFormat) Set the date format to use for parsing the date replacement constantvoid
setDateReplacementValue
(String dateConstant) Set the date replacement valuevoid
Set environment variables to use.boolean
setInputFormat
(Instances instanceInfo) Sets the format of the input instances.void
setNominalStringReplacementValue
(String nominalStringConstant) Set the nominal/string replacement valuevoid
setNumericReplacementValue
(String numericConstant) Set the numeric replacement valuevoid
setOptions
(String[] options) Parses a given list of options.Methods inherited from class weka.filters.unsupervised.attribute.PotentialClassIgnorer
getIgnoreClass, getOutputFormat, ignoreClassTipText, setIgnoreClass
Methods inherited from class weka.filters.Filter
batchFilterFile, batchFinished, debugTipText, doNotCheckCapabilitiesTipText, filterFile, getCapabilities, getCopyOfInputFormat, getDebug, getDoNotCheckCapabilities, isFirstBatchDone, isNewBatch, isOutputFormatDefined, makeCopies, makeCopy, mayRemoveInstanceAfterFirstBatchDone, numPendingOutput, output, outputPeek, postExecution, preExecution, run, runFilter, setDebug, setDoNotCheckCapabilities, toString, useFilter, wekaStaticWrapper
-
Constructor Details
-
ReplaceMissingWithUserConstant
public ReplaceMissingWithUserConstant()
-
-
Method Details
-
globalInfo
Returns a string describing this filter- Returns:
- a description of the filter suitable for displaying in the explorer/experimenter gui
-
getCapabilities
Description copied from class:Filter
Returns the Capabilities of this filter. Derived filters have to override this method to enable capabilities.- Specified by:
getCapabilities
in interfaceCapabilitiesHandler
- Overrides:
getCapabilities
in classFilter
- Returns:
- the capabilities of this object
- See Also:
-
listOptions
Description copied from class:PotentialClassIgnorer
Returns an enumeration describing the available options.- Specified by:
listOptions
in interfaceOptionHandler
- Overrides:
listOptions
in classPotentialClassIgnorer
- Returns:
- an enumeration of all the available options.
-
setOptions
Parses a given list of options. Valid options are:-A <index1,index2-index4,... | att-name1,att-name2,...> Specify list of attributes to replace missing values for (as weka range list of indices or a comma separated list of attribute names). (default: consider all attributes)
-N Specify the replacement constant for nominal/string attributes
-R Specify the replacement constant for numeric attributes (default: 0)
-D Specify the replacement constant for date attributes
-F Specify the date format for parsing the replacement date constant (default: yyyy-MM-dd'T'HH:mm:ss)
-unset-class-temporarily Unsets the class index temporarily before the filter is applied to the data. (default: no)
- Specified by:
setOptions
in interfaceOptionHandler
- Overrides:
setOptions
in classPotentialClassIgnorer
- Parameters:
options
- the list of options as an array of strings- Throws:
Exception
- if an option is not supported
-
getOptions
Description copied from class:PotentialClassIgnorer
Gets the current settings of the filter.- Specified by:
getOptions
in interfaceOptionHandler
- Overrides:
getOptions
in classPotentialClassIgnorer
- Returns:
- an array of strings suitable for passing to setOptions
-
attributesTipText
Tip text for this property suitable for displaying in the GUI.- Returns:
- the tip text for this property.
-
setAttributes
Set the list of attributes to consider for replacing missing values- Parameters:
range
- the list of attributes to consider
-
getAttributes
Get the list of attributes to consider for replacing missing values- Returns:
- the list of attributes to consider
-
nominalStringReplacementValueTipText
Tip text for this property suitable for displaying in the GUI.- Returns:
- the tip text for this property.
-
getNominalStringReplacementValue
Get the nominal/string replacement value- Returns:
- the nominal/string replacement value
-
setNominalStringReplacementValue
Set the nominal/string replacement value- Parameters:
nominalStringConstant
- the nominal/string constant to use
-
numericReplacementValueTipText
Tip text for this property suitable for displaying in the GUI.- Returns:
- the tip text for this property.
-
getNumericReplacementValue
Get the numeric replacement value- Returns:
- the numeric replacement value
-
setNumericReplacementValue
Set the numeric replacement value- Parameters:
numericConstant
- the numeric replacement value
-
dateReplacementValueTipText
Tip text for this property suitable for displaying in the GUI.- Returns:
- the tip text for this property.
-
setDateReplacementValue
Set the date replacement value- Parameters:
dateConstant
- the date replacement value
-
getDateReplacementValue
Get the date replacement value- Returns:
- the date replacement value
-
dateFormatTipText
Tip text for this property suitable for displaying in the GUI.- Returns:
- the tip text for this property.
-
setDateFormat
Set the date format to use for parsing the date replacement constant- Parameters:
dateFormat
- the date format to use
-
getDateFormat
Get the date format to use for parsing the date replacement constant- Returns:
- the date format to use
-
setInputFormat
Description copied from class:PotentialClassIgnorer
Sets the format of the input instances. If the filter is able to determine the output format before seeing any input instances, it does so here. This default implementation clears the output format and output queue, and the new batch flag is set. Overriders should callsuper.setInputFormat(Instances)
- Overrides:
setInputFormat
in classPotentialClassIgnorer
- 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
Description copied from class:Filter
Input an instance for filtering. Ordinarily the instance is processed and made available for output immediately. Some filters require all instances be read before producing output, in which case output instances should be collected after calling batchFinished(). If the input marks the start of a new batch, the output queue is cleared. This default implementation assumes all instance conversion will occur when batchFinished() is called.- Overrides:
input
in classFilter
- Parameters:
inst
- 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.
-
setEnvironment
Description copied from interface:EnvironmentHandler
Set environment variables to use.- Specified by:
setEnvironment
in interfaceEnvironmentHandler
- Parameters:
env
- the environment variables to use
-
getRevision
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Overrides:
getRevision
in classFilter
- Returns:
- the revision
-
main
Main method for testing this class.- Parameters:
args
- should contain arguments to the filter: use -h for help
-