|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.classifiers.Classifier
weka.classifiers.bayes.ComplementNaiveBayes
Class for building and using a Complement class Naive Bayes classifier. For more information see,
ICML-2003 Tackling the poor assumptions of Naive Bayes Text Classifiers P.S.: TF, IDF and length normalization transforms, as described in the paper, can be performed through weka.filters.unsupervised.StringToWordVector.
Valid options for the classifier are:
-N
Normalizes word weights for each class.
-S val
The smoothing value to use to avoid zero WordGivenClass probabilities
(default 1.0).
Field Summary | |
private Instances |
header
The instances header that'll be used in toString |
private boolean |
m_normalizeWordWeights
True if the words weights are to be normalized |
private int |
numClasses
Holds the number of Class values present in the set of specified instances |
private double |
smoothingParameter
Holds the smoothing value to avoid word probabilities of zero. |
private double[][] |
wordWeights
Weight of words for each class. |
Fields inherited from class weka.classifiers.Classifier |
m_Debug |
Constructor Summary | |
ComplementNaiveBayes()
|
Method Summary | |
void |
buildClassifier(Instances instances)
Generates the classifier. |
double |
classifyInstance(Instance instance)
Classifies a given instance. |
boolean |
getNormalizeWordWeights()
Returns true if the word weights for each class are to be normalized |
java.lang.String[] |
getOptions()
Gets the current settings of the classifier. |
double |
getSmoothingParameter()
Gets the smoothing value to be used to avoid zero WordGivenClass probabilities. |
java.lang.String |
globalInfo()
Returns a string describing this classifier |
java.util.Enumeration |
listOptions()
Returns an enumeration describing the available options. |
static void |
main(java.lang.String[] argv)
Main method for testing this class. |
java.lang.String |
normalizeWordWeightsTipText()
Returns the tip text for this property |
void |
setNormalizeWordWeights(boolean doNormalize)
Sets whether if the word weights for each class should be normalized |
void |
setOptions(java.lang.String[] options)
Parses a given list of options. |
void |
setSmoothingParameter(double val)
Sets the smoothing value used to avoid zero WordGivenClass probabilities |
java.lang.String |
smoothingParameterTipText()
Returns the tip text for this property |
java.lang.String |
toString()
Prints out the internal model built by the classifier. |
Methods inherited from class weka.classifiers.Classifier |
debugTipText, distributionForInstance, forName, getDebug, makeCopies, setDebug |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private double[][] wordWeights
private double smoothingParameter
private boolean m_normalizeWordWeights
private int numClasses
private Instances header
Constructor Detail |
public ComplementNaiveBayes()
Method Detail |
public java.util.Enumeration listOptions()
listOptions
in interface OptionHandler
listOptions
in class Classifier
public java.lang.String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class Classifier
public void setOptions(java.lang.String[] options) throws java.lang.Exception
-N
Normalizes word weights for each class.
-S val
The smoothing value to use to avoid zero WordGivenClass probabilities
(default 1.0).
setOptions
in interface OptionHandler
setOptions
in class Classifier
options
- the list of options as an array of strings
java.lang.Exception
- if an option is not supportedpublic boolean getNormalizeWordWeights()
public void setNormalizeWordWeights(boolean doNormalize)
public java.lang.String normalizeWordWeightsTipText()
public double getSmoothingParameter()
public void setSmoothingParameter(double val)
public java.lang.String smoothingParameterTipText()
public java.lang.String globalInfo()
public void buildClassifier(Instances instances) throws java.lang.Exception
buildClassifier
in class Classifier
instances
- set of instances serving as training data
java.lang.Exception
- if the classifier has not been built successfullypublic double classifyInstance(Instance instance) throws java.lang.Exception
The classification rule is:
MinC(forAllWords(ti*Wci))
where
ti is the frequency of word i in the given instance
Wci is the weight of word i in Class c.
For more information see section 4.4 of the paper mentioned above in the classifiers description.
classifyInstance
in class Classifier
instance
- the instance to be classified
if
- the classifier has not been built yet.
java.lang.Exception
- if an error occurred during the predictionpublic java.lang.String toString()
public static void main(java.lang.String[] argv)
argv
- the options
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |