org.apache.mahout.classifier.bayes
Class ClassifierContext

java.lang.Object
  extended by org.apache.mahout.classifier.bayes.ClassifierContext

public class ClassifierContext
extends Object

The Classifier Wrapper used for choosing the Algorithm and Datastore


Constructor Summary
ClassifierContext(Algorithm algorithm, Datastore datastore)
           
 
Method Summary
 ClassifierResult classifyDocument(String[] document, String defaultCategory)
          Classify the document and return the Result
 ClassifierResult[] classifyDocument(String[] document, String defaultCategory, int numResults)
          Classify the document and return the top numResults
 Collection<String> getLabels()
          Gets the labels in the given model
 void initialize()
          Initializes the Context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassifierContext

public ClassifierContext(Algorithm algorithm,
                         Datastore datastore)
Method Detail

initialize

public void initialize()
                throws InvalidDatastoreException
Initializes the Context. Gets the necessary data and checks if the Datastore is valid

Throws:
InvalidDatastoreException

classifyDocument

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

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

classifyDocument

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

Parameters:
document - The document to classify
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

getLabels

public Collection<String> getLabels()
                             throws InvalidDatastoreException
Gets the labels in the given model

Returns:
Collection of Labels
Throws:
InvalidDatastoreException


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