org.apache.mahout.classifier.bayes
Interface Algorithm

All Known Implementing Classes:
BayesAlgorithm, CBayesAlgorithm

public interface Algorithm

The algorithm interface for implementing variations of bayes Algorithm


Method Summary
 ClassifierResult classifyDocument(String[] document, Datastore datastore, String defaultCategory)
          Classify the document and return the Result
 ClassifierResult[] classifyDocument(String[] document, Datastore datastore, String defaultCategory, int numResults)
          Classify the document and return the top numResults
 double documentWeight(Datastore datastore, String label, 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, String label, String feature)
          Get the weighted probability of the feature.
 Collection<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.
 

Method Detail

initialize

void initialize(Datastore datastore)
                throws InvalidDatastoreException
Initialize the data store and verifies the data in it.

Parameters:
datastore -
Throws:
InvalidDatastoreException

classifyDocument

ClassifierResult classifyDocument(String[] document,
                                  Datastore datastore,
                                  String defaultCategory)
                                  throws InvalidDatastoreException
Classify the document and return the Result

Parameters:
document - The document to classify
datastore - The data store(InMemory)
defaultCategory - The default category to assign Ties are broken by comparing the category
Returns:
A Collection of ClassifierResults.
Throws:
InvalidDatastoreException

classifyDocument

ClassifierResult[] classifyDocument(String[] document,
                                    Datastore datastore,
                                    String defaultCategory,
                                    int numResults)
                                    throws InvalidDatastoreException
Classify the document and return the top numResults

Parameters:
document - The document to classify
datastore - The Datastore (InMemory)
defaultCategory - The default category to assign
numResults - The maximum number of results to return, ranked by score. Ties are broken by comparing the category
Returns:
A Collection of ClassifierResults.
Throws:
InvalidDatastoreException

featureWeight

double featureWeight(Datastore datastore,
                     String label,
                     String feature)
                     throws InvalidDatastoreException
Get the weighted probability of the feature.

Parameters:
datastore - The Datastore (InMemory)
label - The label of the feature
feature - The feature to calc. the prob. for
Returns:
The weighted probability
Throws:
InvalidDatastoreException

documentWeight

double documentWeight(Datastore datastore,
                      String label,
                      String[] document)
Calculate the document weight as the dot product of document vector and the corresponding weight vector of a particular class

Parameters:
datastore - The Datastore (InMemory)
label - The label to calculate the probability of
document - The document
Returns:
The probability
See Also:
featureWeight(Datastore, String, String)

getLabels

Collection<String> getLabels(Datastore datastore)
                             throws InvalidDatastoreException
Returns the labels in the given Model

Parameters:
datastore - The Datastore (InMemory)
Returns:
Collection of labels
Throws:
InvalidDatastoreException


Copyright © 2008-2012 The Apache Software Foundation. All Rights Reserved.