|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcc.mallet.classify.ClassifierTrainer<NaiveBayes>
cc.mallet.classify.NaiveBayesTrainer
public class NaiveBayesTrainer
Class used to generate a NaiveBayes classifier from a set of training data. In an Bayes classifier, the p(Classification|Data) = p(Data|Classification)p(Classification)/p(Data)
To compute the likelihood:
p(Data|Classification) = p(d1,d2,..dn | Classification)
Naive Bayes makes the assumption that all of the data are conditionally
independent given the Classification:
p(d1,d2,...dn | Classification) = p(d1|Classification)p(d2|Classification)..
As with other classifiers in Mallet, NaiveBayes is implemented as two classes: a trainer and a classifier. The NaiveBayesTrainer produces estimates of the various p(dn|Classifier) and contructs this class with those estimates.
A call to train() or incrementalTrain() produces a
NaiveBayes classifier that can
can be used to classify instances. A call to incrementalTrain() does not throw
away the internal state of the trainer; subsequent calls to incrementalTrain()
train by extending the previous training set.
A NaiveBayesTrainer can be persisted using serialization.
NaiveBayes,
Serialized Form| Nested Class Summary | |
|---|---|
static class |
NaiveBayesTrainer.Factory
|
| Nested classes/interfaces inherited from class cc.mallet.classify.ClassifierTrainer |
|---|
ClassifierTrainer.ByActiveLearning<C extends Classifier>, ClassifierTrainer.ByIncrements<C extends Classifier>, ClassifierTrainer.ByInstanceIncrements<C extends Classifier>, ClassifierTrainer.ByOptimization<C extends Classifier> |
| Field Summary |
|---|
| Fields inherited from class cc.mallet.classify.ClassifierTrainer |
|---|
finishedTraining, validationSet |
| Constructor Summary | |
|---|---|
NaiveBayesTrainer()
|
|
NaiveBayesTrainer(NaiveBayes initialClassifier)
|
|
NaiveBayesTrainer(Pipe instancePipe)
|
|
| Method Summary | |
|---|---|
boolean |
alphabetsMatch(AlphabetCarrying object)
|
Alphabet |
getAlphabet()
|
Alphabet[] |
getAlphabets()
|
NaiveBayes |
getClassifier()
|
double |
getDocLengthNormalization()
|
Multinomial.Estimator |
getFeatureMultinomialEstimator()
Get the MultinomialEstimator instance used to specify the type of estimator for features. |
Multinomial.Estimator |
getPriorMultinomialEstimator()
Get the MultinomialEstimator instance used to specify the type of estimator for priors. |
NaiveBayesTrainer |
setDocLengthNormalization(double d)
|
NaiveBayesTrainer |
setFeatureMultinomialEstimator(Multinomial.Estimator me)
Set the Multinomial Estimator used for features. |
NaiveBayesTrainer |
setPriorMultinomialEstimator(Multinomial.Estimator me)
Set the Multinomial Estimator used for priors. |
java.lang.String |
toString()
Create a NaiveBayes classifier from a set of training data and the previous state of the trainer. |
NaiveBayes |
train(InstanceList trainingList)
Create a NaiveBayes classifier from a set of training data. |
NaiveBayes |
trainIncremental(Instance instance)
|
NaiveBayes |
trainIncremental(InstanceList trainingInstancesToAdd)
|
| Methods inherited from class cc.mallet.classify.ClassifierTrainer |
|---|
getValidationInstances, isFinishedTraining, setValidationInstances |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public NaiveBayesTrainer(NaiveBayes initialClassifier)
public NaiveBayesTrainer(Pipe instancePipe)
public NaiveBayesTrainer()
| Method Detail |
|---|
public NaiveBayes getClassifier()
getClassifier in class ClassifierTrainer<NaiveBayes>public NaiveBayesTrainer setDocLengthNormalization(double d)
public double getDocLengthNormalization()
public Multinomial.Estimator getFeatureMultinomialEstimator()
public NaiveBayesTrainer setFeatureMultinomialEstimator(Multinomial.Estimator me)
me - to be cloned on next call to train() or first call
to incrementalTrain()public Multinomial.Estimator getPriorMultinomialEstimator()
public NaiveBayesTrainer setPriorMultinomialEstimator(Multinomial.Estimator me)
me - to be cloned on next call to train() or first call
to incrementalTrain()public NaiveBayes train(InstanceList trainingList)
train in class ClassifierTrainer<NaiveBayes>trainingList - The InstanceList to be used to train the classifier.
Within each instance the data slot is an instance of FeatureVector and the
target slot is an instance of LabelingvalidationList - Currently unusedtestSet - Currently unusedevaluator - Currently unusedinitialClassifier - Currently unused
public NaiveBayes trainIncremental(InstanceList trainingInstancesToAdd)
trainIncremental in interface ClassifierTrainer.ByIncrements<NaiveBayes>public NaiveBayes trainIncremental(Instance instance)
trainIncremental in interface ClassifierTrainer.ByInstanceIncrements<NaiveBayes>public java.lang.String toString()
toString in class java.lang.ObjecttrainingList - The InstanceList to be used to train the classifier.
Within each instance the data slot is an instance of FeatureVector and the
target slot is an instance of LabelingvalidationList - Currently unusedtestSet - Currently unusedevaluator - Currently unusedinitialClassifier - Currently unused
public boolean alphabetsMatch(AlphabetCarrying object)
public Alphabet getAlphabet()
getAlphabet in interface AlphabetCarryingpublic Alphabet[] getAlphabets()
getAlphabets in interface AlphabetCarrying
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||