|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.mahout.classifier.bayes.algorithm.CBayesAlgorithm
public class CBayesAlgorithm
Class implementing the Complementary Naive Bayes Classifier Algorithm
Constructor Summary | |
---|---|
CBayesAlgorithm()
|
Method Summary | |
---|---|
ClassifierResult |
classifyDocument(java.lang.String[] document,
Datastore datastore,
java.lang.String defaultCategory)
Classify the document and return the Result |
ClassifierResult[] |
classifyDocument(java.lang.String[] document,
Datastore datastore,
java.lang.String defaultCategory,
int numResults)
Classify the document and return the top numResults |
double |
documentWeight(Datastore datastore,
java.lang.String label,
java.lang.String[] document)
Calculate the document weight as the dot product of document vector and the corresponding weight vector of a particular class |
double |
featureWeight(Datastore datastore,
java.lang.String label,
java.lang.String feature)
Get the weighted probability of the feature. |
java.util.Collection<java.lang.String> |
getLabels(Datastore datastore)
Returns the labels in the given Model |
void |
initialize(Datastore datastore)
Initialize the data store and verifies the data in it. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CBayesAlgorithm()
Method Detail |
---|
public ClassifierResult classifyDocument(java.lang.String[] document, Datastore datastore, java.lang.String defaultCategory) throws InvalidDatastoreException
Algorithm
classifyDocument
in interface Algorithm
document
- The document to classifydatastore
- The data store(InMemory, HBase)defaultCategory
- The default category to assign Ties are broken by comparing the category
ClassifierResult
s.
InvalidDatastoreException
public ClassifierResult[] classifyDocument(java.lang.String[] document, Datastore datastore, java.lang.String defaultCategory, int numResults) throws InvalidDatastoreException
Algorithm
numResults
classifyDocument
in interface Algorithm
document
- The document to classifydatastore
- The Datastore
(InMemory, HBase)defaultCategory
- The default category to assignnumResults
- The maximum number of results to return, ranked by score. Ties are broken by comparing the
category
ClassifierResult
s.
InvalidDatastoreException
public double featureWeight(Datastore datastore, java.lang.String label, java.lang.String feature) throws InvalidDatastoreException
Algorithm
featureWeight
in interface Algorithm
datastore
- The Datastore
(InMemory, HBase)label
- The label of the featurefeature
- The feature to calc. the prob. for
InvalidDatastoreException
public void initialize(Datastore datastore) throws InvalidDatastoreException
Algorithm
initialize
in interface Algorithm
InvalidDatastoreException
public double documentWeight(Datastore datastore, java.lang.String label, java.lang.String[] document) throws InvalidDatastoreException
Algorithm
documentWeight
in interface Algorithm
datastore
- The Datastore
(InMemory, HBase)label
- The label to calculate the probability ofdocument
- The document
InvalidDatastoreException
Algorithm.featureWeight(Datastore, String, String)
public java.util.Collection<java.lang.String> getLabels(Datastore datastore) throws InvalidDatastoreException
Algorithm
getLabels
in interface Algorithm
datastore
- The Datastore
(InMemory, HBase)
Collection
of labels
InvalidDatastoreException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |