Class ReplaceMissingWithUserConstant
- java.lang.Object
-
- weka.filters.Filter
-
- weka.filters.unsupervised.attribute.PotentialClassIgnorer
-
- weka.filters.unsupervised.attribute.ReplaceMissingWithUserConstant
-
- All Implemented Interfaces:
java.io.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: 14534 $
- Author:
- Mark Hall (mhall{[at]}pentaho{[dot]}com)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ReplaceMissingWithUserConstant()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringattributesTipText()Tip text for this property suitable for displaying in the GUI.java.lang.StringdateFormatTipText()Tip text for this property suitable for displaying in the GUI.java.lang.StringdateReplacementValueTipText()Tip text for this property suitable for displaying in the GUI.java.lang.StringgetAttributes()Get the list of attributes to consider for replacing missing valuesCapabilitiesgetCapabilities()Returns the Capabilities of this filter.java.lang.StringgetDateFormat()Get the date format to use for parsing the date replacement constantjava.lang.StringgetDateReplacementValue()Get the date replacement valuejava.lang.StringgetNominalStringReplacementValue()Get the nominal/string replacement valuejava.lang.StringgetNumericReplacementValue()Get the numeric replacement valuejava.lang.String[]getOptions()Gets the current settings of the filter.java.lang.StringgetRevision()Returns the revision string.java.lang.StringglobalInfo()Returns a string describing this filterbooleaninput(Instance inst)Input an instance for filtering.java.util.Enumeration<Option>listOptions()Returns an enumeration describing the available options.static voidmain(java.lang.String[] args)Main method for testing this class.java.lang.StringnominalStringReplacementValueTipText()Tip text for this property suitable for displaying in the GUI.java.lang.StringnumericReplacementValueTipText()Tip text for this property suitable for displaying in the GUI.voidsetAttributes(java.lang.String range)Set the list of attributes to consider for replacing missing valuesvoidsetDateFormat(java.lang.String dateFormat)Set the date format to use for parsing the date replacement constantvoidsetDateReplacementValue(java.lang.String dateConstant)Set the date replacement valuevoidsetEnvironment(Environment env)Set environment variables to use.booleansetInputFormat(Instances instanceInfo)Sets the format of the input instances.voidsetNominalStringReplacementValue(java.lang.String nominalStringConstant)Set the nominal/string replacement valuevoidsetNumericReplacementValue(java.lang.String numericConstant)Set the numeric replacement valuevoidsetOptions(java.lang.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
-
-
-
-
Method Detail
-
globalInfo
public java.lang.String globalInfo()
Returns a string describing this filter- Returns:
- a description of the filter suitable for displaying in the explorer/experimenter gui
-
getCapabilities
public Capabilities getCapabilities()
Description copied from class:FilterReturns the Capabilities of this filter. Derived filters have to override this method to enable capabilities.- Specified by:
getCapabilitiesin interfaceCapabilitiesHandler- Overrides:
getCapabilitiesin classFilter- Returns:
- the capabilities of this object
- See Also:
Capabilities
-
listOptions
public java.util.Enumeration<Option> listOptions()
Description copied from class:PotentialClassIgnorerReturns an enumeration describing the available options.- Specified by:
listOptionsin interfaceOptionHandler- Overrides:
listOptionsin classPotentialClassIgnorer- Returns:
- an enumeration of all the available options.
-
setOptions
public void setOptions(java.lang.String[] options) throws java.lang.ExceptionParses 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:
setOptionsin interfaceOptionHandler- Overrides:
setOptionsin classPotentialClassIgnorer- Parameters:
options- the list of options as an array of strings- Throws:
java.lang.Exception- if an option is not supported
-
getOptions
public java.lang.String[] getOptions()
Description copied from class:PotentialClassIgnorerGets the current settings of the filter.- Specified by:
getOptionsin interfaceOptionHandler- Overrides:
getOptionsin classPotentialClassIgnorer- Returns:
- an array of strings suitable for passing to setOptions
-
attributesTipText
public java.lang.String attributesTipText()
Tip text for this property suitable for displaying in the GUI.- Returns:
- the tip text for this property.
-
setAttributes
public void setAttributes(java.lang.String range)
Set the list of attributes to consider for replacing missing values- Parameters:
range- the list of attributes to consider
-
getAttributes
public java.lang.String getAttributes()
Get the list of attributes to consider for replacing missing values- Returns:
- the list of attributes to consider
-
nominalStringReplacementValueTipText
public java.lang.String nominalStringReplacementValueTipText()
Tip text for this property suitable for displaying in the GUI.- Returns:
- the tip text for this property.
-
getNominalStringReplacementValue
public java.lang.String getNominalStringReplacementValue()
Get the nominal/string replacement value- Returns:
- the nominal/string replacement value
-
setNominalStringReplacementValue
public void setNominalStringReplacementValue(java.lang.String nominalStringConstant)
Set the nominal/string replacement value- Parameters:
nominalStringConstant- the nominal/string constant to use
-
numericReplacementValueTipText
public java.lang.String numericReplacementValueTipText()
Tip text for this property suitable for displaying in the GUI.- Returns:
- the tip text for this property.
-
getNumericReplacementValue
public java.lang.String getNumericReplacementValue()
Get the numeric replacement value- Returns:
- the numeric replacement value
-
setNumericReplacementValue
public void setNumericReplacementValue(java.lang.String numericConstant)
Set the numeric replacement value- Parameters:
numericConstant- the numeric replacement value
-
dateReplacementValueTipText
public java.lang.String dateReplacementValueTipText()
Tip text for this property suitable for displaying in the GUI.- Returns:
- the tip text for this property.
-
setDateReplacementValue
public void setDateReplacementValue(java.lang.String dateConstant)
Set the date replacement value- Parameters:
dateConstant- the date replacement value
-
getDateReplacementValue
public java.lang.String getDateReplacementValue()
Get the date replacement value- Returns:
- the date replacement value
-
dateFormatTipText
public java.lang.String dateFormatTipText()
Tip text for this property suitable for displaying in the GUI.- Returns:
- the tip text for this property.
-
setDateFormat
public void setDateFormat(java.lang.String dateFormat)
Set the date format to use for parsing the date replacement constant- Parameters:
dateFormat- the date format to use
-
getDateFormat
public java.lang.String getDateFormat()
Get the date format to use for parsing the date replacement constant- Returns:
- the date format to use
-
setInputFormat
public boolean setInputFormat(Instances instanceInfo) throws java.lang.Exception
Description copied from class:PotentialClassIgnorerSets 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:
setInputFormatin 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:
java.lang.Exception- if the inputFormat can't be set successfully
-
input
public boolean input(Instance inst) throws java.lang.Exception
Description copied from class:FilterInput 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:
inputin classFilter- Parameters:
inst- the input instance- Returns:
- true if the filtered instance may now be collected with output().
- Throws:
java.lang.NullPointerException- if the input format has not been defined.java.lang.Exception- if the input instance was not of the correct format or if there was a problem with the filtering.
-
setEnvironment
public void setEnvironment(Environment env)
Description copied from interface:EnvironmentHandlerSet environment variables to use.- Specified by:
setEnvironmentin interfaceEnvironmentHandler- Parameters:
env- the environment variables to use
-
getRevision
public java.lang.String getRevision()
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Overrides:
getRevisionin classFilter- Returns:
- the revision
-
main
public static void main(java.lang.String[] args)
Main method for testing this class.- Parameters:
args- should contain arguments to the filter: use -h for help
-
-