|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.classifiers.Classifier
weka.classifiers.bayes.NaiveBayesMultinomial
The core equation for this classifier: P[Ci|D] = (P[D|Ci] x P[Ci]) / P[D] (Bayes rule) where Ci is class i and D is a document
Field Summary | |
(package private) Instances |
headerInfo
|
private double[] |
lnFactorialCache
|
private int |
numAttributes
|
private int |
numClasses
|
private double[] |
probOfClass
|
private double[][] |
probOfWordGivenClass
|
Fields inherited from class weka.classifiers.Classifier |
m_Debug |
Constructor Summary | |
NaiveBayesMultinomial()
|
Method Summary | |
void |
buildClassifier(Instances instances)
Generates the classifier. |
double[] |
distributionForInstance(Instance instance)
Calculates the class membership probabilities for the given test instance. |
java.lang.String |
globalInfo()
Returns a string describing this classifier |
double |
lnFactorial(int n)
Fast computation of ln(n!) |
static void |
main(java.lang.String[] argv)
Main method for testing this class. |
private double |
probOfDocGivenClass(Instance inst,
int classIndex)
log(N!) |
java.lang.String |
toString()
|
Methods inherited from class weka.classifiers.Classifier |
classifyInstance, debugTipText, forName, getDebug, getOptions, listOptions, makeCopies, setDebug, setOptions |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private double[][] probOfWordGivenClass
private double[] probOfClass
private int numAttributes
private int numClasses
private double[] lnFactorialCache
Instances headerInfo
Constructor Detail |
public NaiveBayesMultinomial()
Method Detail |
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 generated successfullypublic double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance
in class Classifier
instance
- the instance to be classified
java.lang.Exception
- if there is a problem generating the predictionprivate double probOfDocGivenClass(Instance inst, int classIndex)
inst
- The instance to be classifiedclassIndex
- The index of the class we are calculating the probability with respect to
public double lnFactorial(int n)
n
- the integer
public 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 |