Class ClassConditionalProbabilities
java.lang.Object
weka.filters.Filter
weka.filters.SimpleFilter
weka.filters.SimpleBatchFilter
weka.filters.supervised.attribute.ClassConditionalProbabilities
- All Implemented Interfaces:
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:
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:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the Capabilities of this filter.Get the naive Bayes estimator in useboolean
Get whether nominal attributes are to be excluded from the transformationboolean
Get whether numeric attributes are being excluded from the transformationint
Get the minimum number of values a nominal attribute must have in order to be transformed.Get the remove filter in useReturns the revision string.boolean
If true, when generating attributes, spread weight of old attribute across new attributes.Global help info for this methodboolean
Input an instance for filtering.static void
Main method for testing this classvoid
Set the naive Bayes estimator to usevoid
setExcludeNominalAttributes
(boolean e) Set whether nominal attributes are to be excluded from the transformationvoid
setExcludeNumericAttributes
(boolean e) Set whether numeric attributes are being excluded from the transformationvoid
Set the minimum number of values a nominal attribute must have in order to be transformed.void
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
-
Constructor Details
-
ClassConditionalProbabilities
public ClassConditionalProbabilities()
-
-
Method Details
-
main
Main method for testing this class- Parameters:
args
- args
-
globalInfo
Global help info for this method- Specified by:
globalInfo
in classSimpleFilter
- 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
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 classSimpleBatchFilter
- Parameters:
inst
- the input instance- Returns:
- true if the filtered instance may now be collected with output().
- Throws:
IllegalStateException
- if no input structure has been definedException
- if something goes wrong- See Also:
-
getCapabilities
Returns the Capabilities of this filter.- Specified by:
getCapabilities
in interfaceCapabilitiesHandler
- Overrides:
getCapabilities
in classFilter
- Returns:
- the capabilities of this object
- See Also:
-
getRevision
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Overrides:
getRevision
in classFilter
- Returns:
- the revision
-
getEstimator
Get the naive Bayes estimator in use- Returns:
- the naive Bayes estimator
-
setEstimator
Set the naive Bayes estimator to use- Parameters:
nb
- the naive Bayes estimator to use
-
getRemoveFilter
Get the remove filter in use- Returns:
-
setRemoveFilter
-