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

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 Details

    • ReplaceMissingWithUserConstant

      public ReplaceMissingWithUserConstant()
  • Method Details

    • globalInfo

      public 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: Filter
      Returns the Capabilities of this filter. Derived filters have to override this method to enable capabilities.
      Specified by:
      getCapabilities in interface CapabilitiesHandler
      Overrides:
      getCapabilities in class Filter
      Returns:
      the capabilities of this object
      See Also:
    • listOptions

      public Enumeration<Option> listOptions()
      Description copied from class: PotentialClassIgnorer
      Returns an enumeration describing the available options.
      Specified by:
      listOptions in interface OptionHandler
      Overrides:
      listOptions in class PotentialClassIgnorer
      Returns:
      an enumeration of all the available options.
    • setOptions

      public void setOptions(String[] options) throws Exception
      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 interface OptionHandler
      Overrides:
      setOptions in class PotentialClassIgnorer
      Parameters:
      options - the list of options as an array of strings
      Throws:
      Exception - if an option is not supported
    • getOptions

      public String[] getOptions()
      Description copied from class: PotentialClassIgnorer
      Gets the current settings of the filter.
      Specified by:
      getOptions in interface OptionHandler
      Overrides:
      getOptions in class PotentialClassIgnorer
      Returns:
      an array of strings suitable for passing to setOptions
    • attributesTipText

      public String attributesTipText()
      Tip text for this property suitable for displaying in the GUI.
      Returns:
      the tip text for this property.
    • setAttributes

      public void setAttributes(String range)
      Set the list of attributes to consider for replacing missing values
      Parameters:
      range - the list of attributes to consider
    • getAttributes

      public String getAttributes()
      Get the list of attributes to consider for replacing missing values
      Returns:
      the list of attributes to consider
    • nominalStringReplacementValueTipText

      public String nominalStringReplacementValueTipText()
      Tip text for this property suitable for displaying in the GUI.
      Returns:
      the tip text for this property.
    • getNominalStringReplacementValue

      public String getNominalStringReplacementValue()
      Get the nominal/string replacement value
      Returns:
      the nominal/string replacement value
    • setNominalStringReplacementValue

      public void setNominalStringReplacementValue(String nominalStringConstant)
      Set the nominal/string replacement value
      Parameters:
      nominalStringConstant - the nominal/string constant to use
    • numericReplacementValueTipText

      public String numericReplacementValueTipText()
      Tip text for this property suitable for displaying in the GUI.
      Returns:
      the tip text for this property.
    • getNumericReplacementValue

      public String getNumericReplacementValue()
      Get the numeric replacement value
      Returns:
      the numeric replacement value
    • setNumericReplacementValue

      public void setNumericReplacementValue(String numericConstant)
      Set the numeric replacement value
      Parameters:
      numericConstant - the numeric replacement value
    • dateReplacementValueTipText

      public String dateReplacementValueTipText()
      Tip text for this property suitable for displaying in the GUI.
      Returns:
      the tip text for this property.
    • setDateReplacementValue

      public void setDateReplacementValue(String dateConstant)
      Set the date replacement value
      Parameters:
      dateConstant - the date replacement value
    • getDateReplacementValue

      public String getDateReplacementValue()
      Get the date replacement value
      Returns:
      the date replacement value
    • dateFormatTipText

      public String dateFormatTipText()
      Tip text for this property suitable for displaying in the GUI.
      Returns:
      the tip text for this property.
    • setDateFormat

      public void setDateFormat(String dateFormat)
      Set the date format to use for parsing the date replacement constant
      Parameters:
      dateFormat - the date format to use
    • getDateFormat

      public 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 Exception
      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 call super.setInputFormat(Instances)
      Overrides:
      setInputFormat in class PotentialClassIgnorer
      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

      public boolean input(Instance inst) throws Exception
      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 class Filter
      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

      public void setEnvironment(Environment env)
      Description copied from interface: EnvironmentHandler
      Set environment variables to use.
      Specified by:
      setEnvironment in interface EnvironmentHandler
      Parameters:
      env - the environment variables to use
    • getRevision

      public String getRevision()
      Returns the revision string.
      Specified by:
      getRevision in interface RevisionHandler
      Overrides:
      getRevision in class Filter
      Returns:
      the revision
    • main

      public static void main(String[] args)
      Main method for testing this class.
      Parameters:
      args - should contain arguments to the filter: use -h for help