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 Description ClassConditionalProbabilities()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CapabilitiesgetCapabilities()Returns the Capabilities of this filter.NaiveBayesgetEstimator()Get the naive Bayes estimator in usebooleangetExcludeNominalAttributes()Get whether nominal attributes are to be excluded from the transformationbooleangetExcludeNumericAttributes()Get whether numeric attributes are being excluded from the transformationintgetNominalConversionThreshold()Get the minimum number of values a nominal attribute must have in order to be transformed.RemovegetRemoveFilter()Get the remove filter in usejava.lang.StringgetRevision()Returns the revision string.booleangetSpreadAttributeWeight()If true, when generating attributes, spread weight of old attribute across new attributes.java.lang.StringglobalInfo()Global help info for this methodbooleaninput(Instance inst)Input an instance for filtering.static voidmain(java.lang.String[] args)Main method for testing this classvoidsetEstimator(NaiveBayes nb)Set the naive Bayes estimator to usevoidsetExcludeNominalAttributes(boolean e)Set whether nominal attributes are to be excluded from the transformationvoidsetExcludeNumericAttributes(boolean e)Set whether numeric attributes are being excluded from the transformationvoidsetNominalConversionThreshold(int n)Set the minimum number of values a nominal attribute must have in order to be transformed.voidsetRemoveFilter(Remove r)voidsetSpreadAttributeWeight(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
-
-
-
-
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:
globalInfoin 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
public boolean input(Instance inst) throws java.lang.Exception
Description copied from class:SimpleBatchFilterInput 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:
inputin classSimpleBatchFilter- 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 definedjava.lang.Exception- if something goes wrong- See Also:
SimpleBatchFilter.batchFinished()
-
getCapabilities
public Capabilities getCapabilities()
Returns the Capabilities of this filter.- Specified by:
getCapabilitiesin interfaceCapabilitiesHandler- Overrides:
getCapabilitiesin classFilter- Returns:
- the capabilities of this object
- See Also:
Capabilities
-
getRevision
public java.lang.String getRevision()
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Overrides:
getRevisionin classFilter- 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)
-
-