weka.filters.supervised.attribute

## Class ClassConditionalProbabilities

- java.lang.Object
- - weka.filters.Filter
  - - weka.filters.SimpleFilter
    - - weka.filters.SimpleBatchFilter
      - - weka.filters.supervised.attribute.ClassConditionalProbabilities

- All Implemented Interfaces:
    java.io.Serializable, CapabilitiesHandler, CapabilitiesIgnorer, CommandlineRunnable, OptionHandler, RevisionHandler, WeightedAttributesHandler, WeightedInstancesHandler

      public class ClassConditionalProbabilities
      extends SimpleBatchFilter
      implements WeightedAttributesHandler, WeightedInstancesHandler

  Converts the values of nominal and/or numeric attributes into class conditional probabilities. If there are k classes, then k new attributes are created for each of the original ones, giving pr(att val | class k).
  Can be useful for converting nominal attributes with a lot of distinct values into something more manageable for learning schemes that can't handle nominal attributes (as opposed to creating binary indicator attributes). For nominal attributes, the user can specify the number values above which an attribute will be converted by this method. Normal distributions are assumed for numeric attributes.

  Valid options are:

       -N
        Don't apply this transformation to numeric attributes

       -C
        Don't apply this transformation to nominal attributes

       -min-values <integer>
        Transform nominal attributes with at least this many values.
        -1 means always transform.

       -output-debug-info
        If set, filter is run in debug mode and
        may output additional info to the console

       -do-not-check-capabilities
        If set, filter capabilities are not checked before filter is built
        (use with caution).

      -spread-attribute-weight
        When generating binary attributes, spread weight of old
        attribute across new attributes. Do not give each new attribute the old weight.

  Version:
    $Revision: $
  Author:
    Mark Hall (mhall{[at]}pentaho{[dot]}com)
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClassConditionalProbabilities()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Capabilities` | `getCapabilities()` Returns the Capabilities of this filter.
    `NaiveBayes` | `getEstimator()` Get the naive Bayes estimator in use
    `boolean` | `getExcludeNominalAttributes()` Get whether nominal attributes are to be excluded from the transformation
    `boolean` | `getExcludeNumericAttributes()` Get whether numeric attributes are being excluded from the transformation
    `int` | `getNominalConversionThreshold()` Get the minimum number of values a nominal attribute must have in order to be transformed.
    `Remove` | `getRemoveFilter()` Get the remove filter in use
    `java.lang.String` | `getRevision()` Returns the revision string.
    `boolean` | `getSpreadAttributeWeight()` If true, when generating attributes, spread weight of old attribute across new attributes.
    `java.lang.String` | `globalInfo()` Global help info for this method
    `boolean` | `input(Instance inst)` Input an instance for filtering.
    `static void` | `main(java.lang.String[] args)` Main method for testing this class
    `void` | `setEstimator(NaiveBayes nb)` Set the naive Bayes estimator to use
    `void` | `setExcludeNominalAttributes(boolean e)` Set whether nominal attributes are to be excluded from the transformation
    `void` | `setExcludeNumericAttributes(boolean e)` Set whether numeric attributes are being excluded from the transformation
    `void` | `setNominalConversionThreshold(int n)` Set the minimum number of values a nominal attribute must have in order to be transformed.
    `void` | `setRemoveFilter(Remove r)`
    `void` | `setSpreadAttributeWeight(boolean p)` If true, when generating attributes, spread weight of old attribute across new attributes.

    - ### Methods inherited from class weka.filters.SimpleBatchFilter

      `allowAccessToFullInputFormat, batchFinished, input`

    - ### Methods inherited from class weka.filters.SimpleFilter

      `setInputFormat`

    - ### Methods inherited from class weka.filters.Filter

      `batchFilterFile, debugTipText, doNotCheckCapabilitiesTipText, filterFile, getCapabilities, getCopyOfInputFormat, getDebug, getDoNotCheckCapabilities, getOptions, getOutputFormat, isFirstBatchDone, isNewBatch, isOutputFormatDefined, listOptions, makeCopies, makeCopy, mayRemoveInstanceAfterFirstBatchDone, numPendingOutput, output, outputPeek, postExecution, preExecution, run, runFilter, setDebug, setDoNotCheckCapabilities, setOptions, toString, useFilter, wekaStaticWrapper`

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

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

- - ### Constructor Detail

    - #### ClassConditionalProbabilities

          public ClassConditionalProbabilities()

  - ### Method Detail

    - #### main

          public static void main(java.lang.String[] args)

      Main method for testing this class
      Parameters:
        `args` - args

    - #### globalInfo

          public java.lang.String globalInfo()

      Global help info for this method
      Specified by:
        `globalInfo` in class `SimpleFilter`
      Returns:
        the global help info

    - #### getExcludeNumericAttributes

          @OptionMetadata(displayName="Exclude numeric attributes",
                          description="Don\'t apply this transformation to numeric attributes",
                          commandLineParamName="N",
                          commandLineParamIsFlag=true,
                          commandLineParamSynopsis="-N",
                          displayOrder=1)
          public boolean getExcludeNumericAttributes()

      Get whether numeric attributes are being excluded from the transformation
      Returns:
        true if numeric attributes are to be excluded

    - #### setExcludeNumericAttributes

          public void setExcludeNumericAttributes(boolean e)

      Set whether numeric attributes are being excluded from the transformation
      Parameters:
        `e` - true if numeric attributes are to be excluded

    - #### getExcludeNominalAttributes

          @OptionMetadata(displayName="Exclude nominal attributes",
                          description="Don\'t apply this transformation to nominal attributes",
                          commandLineParamName="C",
                          commandLineParamIsFlag=true,
                          commandLineParamSynopsis="-C",
                          displayOrder=2)
          public boolean getExcludeNominalAttributes()

      Get whether nominal attributes are to be excluded from the transformation
      Returns:
        true if nominal attributes are to be excluded

    - #### setExcludeNominalAttributes

          public void setExcludeNominalAttributes(boolean e)

      Set whether nominal attributes are to be excluded from the transformation
      Parameters:
        `e` - true if nominal attributes are to be excluded

    - #### setSpreadAttributeWeight

          @OptionMetadata(displayName="Spread weight across new attributes",
                          description="When generating attributes, spread weight of old\nattribute across new attributes. Do not give each new attribute the old weight.",
                          commandLineParamName="spread-attribute-weight",
                          commandLineParamIsFlag=true,
                          commandLineParamSynopsis="-spread-attribute-weight",
                          displayOrder=3)
          public void setSpreadAttributeWeight(boolean p)

      If true, when generating attributes, spread weight of old attribute across new attributes. Do not give each new attribute the old weight.
      Parameters:
        `p` - whether weight is spread

    - #### getSpreadAttributeWeight

          public boolean getSpreadAttributeWeight()

      If true, when generating attributes, spread weight of old attribute across new attributes. Do not give each new attribute the old weight.
      Returns:
        whether weight is spread

    - #### getNominalConversionThreshold

          @OptionMetadata(displayName="Nominal conversion threshold",
                          description="Transform nominal attributes with at least this many values.\n-1 means always transform.",
                          commandLineParamName="min-values",
                          commandLineParamSynopsis="-min-values <integer>",
                          displayOrder=3)
          public int getNominalConversionThreshold()

      Get the minimum number of values a nominal attribute must have in order to be transformed. -1 indicates no minimum (i.e. transform all nominal attributes)
      Returns:
        the number of values of a nominal attribute after which the transformation applies

    - #### setNominalConversionThreshold

          public void setNominalConversionThreshold(int n)

      Set the minimum number of values a nominal attribute must have in order to be transformed. -1 indicates no minimum (i.e. transform all nominal attributes)
      Parameters:
        `n` - the number of values of a nominal attribute after which the transformation applies

    - #### input

          public boolean input(Instance inst)
                        throws java.lang.Exception

      Description copied from class: `SimpleBatchFilter`
      Input an instance for filtering. Filter requires all training instances be read before producing output (calling the method batchFinished() makes the data available). If this instance is part of a new batch, m_NewBatch is set to false.
      Overrides:
        `input` in class `SimpleBatchFilter`
      Parameters:
        `inst` - the input instance
      Returns:
        true if the filtered instance may now be collected with output().
      Throws:
        `java.lang.IllegalStateException` - if no input structure has been defined
        `java.lang.Exception` - if something goes wrong
      See Also:
        `SimpleBatchFilter.batchFinished()`

    - #### getCapabilities

          public Capabilities getCapabilities()

      Returns the Capabilities of this filter.
      Specified by:
        `getCapabilities` in interface `CapabilitiesHandler`
      Overrides:
        `getCapabilities` in class `Filter`
      Returns:
        the capabilities of this object
      See Also:
        `Capabilities`

    - #### getRevision

          public java.lang.String getRevision()

      Returns the revision string.
      Specified by:
        `getRevision` in interface `RevisionHandler`
      Overrides:
        `getRevision` in class `Filter`
      Returns:
        the revision

    - #### getEstimator

          @ProgrammaticProperty
          public NaiveBayes getEstimator()

      Get the naive Bayes estimator in use
      Returns:
        the naive Bayes estimator

    - #### setEstimator

          public void setEstimator(NaiveBayes nb)

      Set the naive Bayes estimator to use
      Parameters:
        `nb` - the naive Bayes estimator to use

    - #### getRemoveFilter

          @ProgrammaticProperty
          public Remove getRemoveFilter()

      Get the remove filter in use
      Returns:

    - #### setRemoveFilter

          public void setRemoveFilter(Remove r)