org.apache.mahout.classifier.naivebayes
Class AbstractNaiveBayesClassifier
java.lang.Object
org.apache.mahout.classifier.AbstractVectorClassifier
org.apache.mahout.classifier.naivebayes.AbstractNaiveBayesClassifier
- Direct Known Subclasses:
- ComplementaryNaiveBayesClassifier, StandardNaiveBayesClassifier
public abstract class AbstractNaiveBayesClassifier
- extends AbstractVectorClassifier
Class implementing the Naive Bayes Classifier Algorithm
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
model
protected NaiveBayesModel model
AbstractNaiveBayesClassifier
public AbstractNaiveBayesClassifier(NaiveBayesModel model)
getScoreForLabelFeature
public abstract double getScoreForLabelFeature(int label,
int feature)
getScoreForLabelInstance
public double getScoreForLabelInstance(int label,
Vector instance)
numCategories
public int numCategories()
- Description copied from class:
AbstractVectorClassifier
- Returns the number of categories for the target variable. A vector classifier
will encode it's output using a zero-based 1 of numCategories encoding.
- Specified by:
numCategories
in class AbstractVectorClassifier
- Returns:
- The number of categories.
classify
public Vector classify(Vector instance)
- Description copied from class:
AbstractVectorClassifier
- Classify a vector returning a vector of numCategories-1 scores. It is assumed that
the score for the missing category is one minus the sum of the scores that are returned.
Note that the missing score is the 0-th score.
- Specified by:
classify
in class AbstractVectorClassifier
- Parameters:
instance
- A feature vector to be classified.
- Returns:
- A vector of probabilities in 1 of n-1 encoding.
classifyScalar
public double classifyScalar(Vector instance)
- Description copied from class:
AbstractVectorClassifier
- Classifies a vector in the special case of a binary classifier where
classify(Vector)
would return a vector with only one element. As such,
using this method can void the allocation of a vector.
- Specified by:
classifyScalar
in class AbstractVectorClassifier
- Parameters:
instance
- The feature vector to be classified.
- Returns:
- The score for category 1.
- See Also:
AbstractVectorClassifier.classify(Vector)
Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.