|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.classifiers.Classifier
weka.classifiers.DistributionClassifier
weka.classifiers.sparse.NaiveBayesSimpleSparse
Class for building and using a simple Naive Bayes classifier that is adapted for Sparse Instances assuming attribute values are counts of the presence of a descriptive token (e.g. frequency of a word in text categorization) and assuming a multinomial model for generation of examples/documents. See: T. Mitchell, Machine Learning, McGraw Hill, 1997, section 6.9 & 6.10 and/or Andrew McCallum and Kamal Nigam, "A Comparison of Event Models for Naive Bayes Text Classification", Papers from the AAAI-98 Workshop on Text Categorization, 1998, pp. 41--48
Field Summary | |
protected int |
m_classIndex
Attribute index for class attribute |
protected double[][] |
m_condProbs
Conditional probabilities of each attribute given each class |
protected boolean |
m_debug
A debug flag |
protected Instances |
m_instances
The instances used for training. |
protected double |
m_m
m parameter for Laplace m estimate, corresponding to size of pseudosample |
protected int |
m_numAttributes
The total number of features |
protected int |
m_numClasses
The number of classes |
protected double[] |
m_priors
The prior probabilities of the classes. |
Constructor Summary | |
NaiveBayesSimpleSparse()
|
Method Summary | |
void |
buildClassifier(Instances instances)
Generates the classifier. |
double[] |
distributionForInstance(Instance instance)
Calculates the class membership probabilities for the given test instance. |
double |
getM()
Get Laplace m parameter that controls amouont of smoothing |
java.lang.String[] |
getOptions()
Gets the current settings of NaiveBayesSimpleSparse. |
java.lang.String |
globalInfo()
|
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 |
mTipText()
|
void |
setM(double m)
Set Laplace m parameter that controls amouont of smoothing |
void |
setOptions(java.lang.String[] options)
Parses a given list of options. |
java.lang.String |
toString()
Returns a description of the classifier. |
double[] |
unNormalizedDistributionForInstance(Instance _instance)
Calculates the class membership probabilities for the given test instance. |
Methods inherited from class weka.classifiers.DistributionClassifier |
calculateEntropy, calculateLabeledInstanceMargin, calculateMargin, classifyInstance |
Methods inherited from class weka.classifiers.Classifier |
forName, makeCopies |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected double[] m_priors
protected double[][] m_condProbs
protected Instances m_instances
protected int m_numClasses
protected int m_classIndex
protected int m_numAttributes
protected double m_m
protected boolean m_debug
Constructor Detail |
public NaiveBayesSimpleSparse()
Method Detail |
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 generated successfullypublic double[] unNormalizedDistributionForInstance(Instance _instance) throws java.lang.Exception
java.lang.Exception
- if distribution can't be computed or if the instance is not a SparseInstancepublic double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance
in class DistributionClassifier
instance
- the instance to be classified
java.lang.Exception
- if distribution can't be computedpublic double getM()
public void setM(double m)
public java.lang.String mTipText()
public java.lang.String globalInfo()
public java.lang.String toString()
public void setOptions(java.lang.String[] options) throws java.lang.Exception
-M num
Set amount of Laplace m estimate smoothing (size of pseudo sample)
setOptions
in interface OptionHandler
options
- the list of options as an array of strings
java.lang.Exception
- if an option is not supportedpublic java.lang.String[] getOptions()
getOptions
in interface OptionHandler
public java.util.Enumeration listOptions()
listOptions
in interface OptionHandler
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 |