weka.filters.unsupervised.attribute

## 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 and Description
    `ReplaceMissingWithUserConstant()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `attributesTipText()` Tip text for this property suitable for displaying in the GUI.
    `java.lang.String` | `dateFormatTipText()` Tip text for this property suitable for displaying in the GUI.
    `java.lang.String` | `dateReplacementValueTipText()` Tip text for this property suitable for displaying in the GUI.
    `java.lang.String` | `getAttributes()` Get the list of attributes to consider for replacing missing values
    `Capabilities` | `getCapabilities()` Returns the Capabilities of this filter.
    `java.lang.String` | `getDateFormat()` Get the date format to use for parsing the date replacement constant
    `java.lang.String` | `getDateReplacementValue()` Get the date replacement value
    `java.lang.String` | `getNominalStringReplacementValue()` Get the nominal/string replacement value
    `java.lang.String` | `getNumericReplacementValue()` Get the numeric replacement value
    `java.lang.String[]` | `getOptions()` Gets the current settings of the filter.
    `java.lang.String` | `getRevision()` Returns the revision string.
    `java.lang.String` | `globalInfo()` Returns a string describing this filter
    `boolean` | `input(Instance inst)` Input an instance for filtering.
    `java.util.Enumeration<Option>` | `listOptions()` Returns an enumeration describing the available options.
    `static void` | `main(java.lang.String[] args)` Main method for testing this class.
    `java.lang.String` | `nominalStringReplacementValueTipText()` Tip text for this property suitable for displaying in the GUI.
    `java.lang.String` | `numericReplacementValueTipText()` Tip text for this property suitable for displaying in the GUI.
    `void` | `setAttributes(java.lang.String range)` Set the list of attributes to consider for replacing missing values
    `void` | `setDateFormat(java.lang.String dateFormat)` Set the date format to use for parsing the date replacement constant
    `void` | `setDateReplacementValue(java.lang.String dateConstant)` Set the date replacement value
    `void` | `setEnvironment(Environment env)` Set environment variables to use.
    `boolean` | `setInputFormat(Instances instanceInfo)` Sets the format of the input instances.
    `void` | `setNominalStringReplacementValue(java.lang.String nominalStringConstant)` Set the nominal/string replacement value
    `void` | `setNumericReplacementValue(java.lang.String numericConstant)` Set the numeric replacement value
    `void` | `setOptions(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`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ReplaceMissingWithUserConstant

          public ReplaceMissingWithUserConstant()

  - ### 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: `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:
        `Capabilities`

    - #### listOptions

          public java.util.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(java.lang.String[] options)
                          throws java.lang.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:
        `java.lang.Exception` - if an option is not supported

    - #### getOptions

          public java.lang.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 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: `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:
        `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: `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:
        `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: `EnvironmentHandler`
      Set environment variables to use.
      Specified by:
        `setEnvironment` in interface `EnvironmentHandler`
      Parameters:
        `env` - the environment variables to use

    - #### getRevision

          public java.lang.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(java.lang.String[] args)

      Main method for testing this class.
      Parameters:
        `args` - should contain arguments to the filter: use -h for help