edu.stanford.nlp.classify
Class NaiveBayesClassifier<L,F>

java.lang.Object
  extended by edu.stanford.nlp.classify.NaiveBayesClassifier<L,F>
All Implemented Interfaces:
Classifier<L,F>, RVFClassifier<L,F>, java.io.Serializable

public class NaiveBayesClassifier<L,F>
extends java.lang.Object
implements Classifier<L,F>, RVFClassifier<L,F>

Author:
Kristina Toutanova (kristina@cs.stanford.edu) A Naive Bayes classifier with a fixed number of features. The features are assumed to have integer values even though RVFDatum will return doubles, Sarah Spikes (sdspikes@cs.stanford.edu) - Templatization. Not sure what the weights counter is supposed to hold; given the weights function it seems to hold Pair, Object> but this seems like a strange thing to expect to be passed in.
See Also:
Serialized Form

Constructor Summary
NaiveBayesClassifier(Counter<Pair<Pair<L,F>,java.lang.Number>> weights, Counter<L> priors, java.util.Set<L> labels)
           
NaiveBayesClassifier(Counter<Pair<Pair<L,F>,java.lang.Number>> weights, Counter<L> priors, java.util.Set<L> labels, java.util.Set<F> features, boolean addZero)
           
 
Method Summary
 float accuracy(java.util.Iterator<RVFDatum<L,F>> exampleIterator)
           
 L classOf(Datum<L,F> example)
           
 L classOf(RVFDatum<L,F> example)
           
 java.util.Collection<L> labels()
           
 void print()
           
 void print(java.io.PrintStream pw)
           
 ClassicCounter<L> scoresOf(Datum<L,F> example)
           
 ClassicCounter<L> scoresOf(RVFDatum<L,F> example)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NaiveBayesClassifier

public NaiveBayesClassifier(Counter<Pair<Pair<L,F>,java.lang.Number>> weights,
                            Counter<L> priors,
                            java.util.Set<L> labels,
                            java.util.Set<F> features,
                            boolean addZero)

NaiveBayesClassifier

public NaiveBayesClassifier(Counter<Pair<Pair<L,F>,java.lang.Number>> weights,
                            Counter<L> priors,
                            java.util.Set<L> labels)
Method Detail

labels

public java.util.Collection<L> labels()
Specified by:
labels in interface Classifier<L,F>

classOf

public L classOf(RVFDatum<L,F> example)
Specified by:
classOf in interface RVFClassifier<L,F>

scoresOf

public ClassicCounter<L> scoresOf(RVFDatum<L,F> example)
Specified by:
scoresOf in interface RVFClassifier<L,F>

classOf

public L classOf(Datum<L,F> example)
Specified by:
classOf in interface Classifier<L,F>

scoresOf

public ClassicCounter<L> scoresOf(Datum<L,F> example)
Specified by:
scoresOf in interface Classifier<L,F>

accuracy

public float accuracy(java.util.Iterator<RVFDatum<L,F>> exampleIterator)

print

public void print(java.io.PrintStream pw)

print

public void print()


Stanford NLP Group