gov.sandia.cognition.learning.function.categorization
Class BinaryVersusCategorizer<InputType,CategoryType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.learning.function.categorization.AbstractCategorizer<InputType,CategoryType>
          extended by gov.sandia.cognition.learning.function.categorization.AbstractDiscriminantCategorizer<InputType,CategoryType,Double>
              extended by gov.sandia.cognition.learning.function.categorization.BinaryVersusCategorizer<InputType,CategoryType>
Type Parameters:
InputType - The type of the input to categorize.
CategoryType - The type of the output categories.
All Implemented Interfaces:
Evaluator<InputType,CategoryType>, Categorizer<InputType,CategoryType>, DiscriminantCategorizer<InputType,CategoryType,Double>, CloneableSerializable, Serializable, Cloneable

public class BinaryVersusCategorizer<InputType,CategoryType>
extends AbstractDiscriminantCategorizer<InputType,CategoryType,Double>

An adapter that allows binary categorizers to be adapted for multi-category problems by applying a binary categorizer to each pair of categories.

Since:
3.0
Author:
Justin Basilico
See Also:
Serialized Form

Nested Class Summary
static class BinaryVersusCategorizer.Learner<InputType,CategoryType>
          A learner for the BinaryVersusCategorizer.
 
Field Summary
protected  Map<Pair<CategoryType,CategoryType>,Evaluator<? super InputType,Boolean>> categoryPairsToEvaluatorMap
          Maps false-true category pairs .
 
Fields inherited from class gov.sandia.cognition.learning.function.categorization.AbstractCategorizer
categories
 
Constructor Summary
BinaryVersusCategorizer()
          Creates a new BinaryVersusCategorizer.
BinaryVersusCategorizer(Set<CategoryType> categories)
          Creates a new BinaryVersusCategorizer with the given categories and an empty set of evaluators.
BinaryVersusCategorizer(Set<CategoryType> categories, Map<Pair<CategoryType,CategoryType>,Evaluator<? super InputType,Boolean>> categoryPairsToEvaluatorMap)
          Creates a new BinaryVersusCategorizer.
 
Method Summary
 BinaryVersusCategorizer<InputType,CategoryType> clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 DefaultWeightedValueDiscriminant<CategoryType> evaluateWithDiscriminant(InputType input)
          Evaluate the categorizer on the given input to produce the expected category plus a discriminant for later producing an ordering of how well items fit into that category.
 Map<Pair<CategoryType,CategoryType>,Evaluator<? super InputType,Boolean>> getCategoryPairsToEvaluatorMap()
          Gets the mapping of false-true category pairs to the binary categorizer that distinguishes them.
 void setCategoryPairsToEvaluatorMap(Map<Pair<CategoryType,CategoryType>,Evaluator<? super InputType,Boolean>> categoryPairsToEvaluatorMap)
          Sets the mapping of false-true category pairs to the binary categorizer that distinguishes them.
 
Methods inherited from class gov.sandia.cognition.learning.function.categorization.AbstractDiscriminantCategorizer
evaluate
 
Methods inherited from class gov.sandia.cognition.learning.function.categorization.AbstractCategorizer
getCategories, setCategories
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.learning.function.categorization.Categorizer
getCategories
 

Field Detail

categoryPairsToEvaluatorMap

protected Map<Pair<CategoryType,CategoryType>,Evaluator<? super InputType,Boolean>> categoryPairsToEvaluatorMap
Maps false-true category pairs .

Constructor Detail

BinaryVersusCategorizer

public BinaryVersusCategorizer()
Creates a new BinaryVersusCategorizer.


BinaryVersusCategorizer

public BinaryVersusCategorizer(Set<CategoryType> categories)
Creates a new BinaryVersusCategorizer with the given categories and an empty set of evaluators.

Parameters:
categories - The possible output categories.

BinaryVersusCategorizer

public BinaryVersusCategorizer(Set<CategoryType> categories,
                               Map<Pair<CategoryType,CategoryType>,Evaluator<? super InputType,Boolean>> categoryPairsToEvaluatorMap)
Creates a new BinaryVersusCategorizer.

Parameters:
categories - The possible output categories.
categoryPairsToEvaluatorMap - The mapping of category pairs to their binary categorizer.
Method Detail

clone

public BinaryVersusCategorizer<InputType,CategoryType> clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object class and removes the exception that it throws. Its default behavior is to automatically create a clone of the exact type of object that the clone is called on and to copy all primitives but to keep all references, which means it is a shallow copy. Extensions of this class may want to override this method (but call super.clone() to implement a "smart copy". That is, to target the most common use case for creating a copy of the object. Because of the default behavior being a shallow copy, extending classes only need to handle fields that need to have a deeper copy (or those that need to be reset). Some of the methods in ObjectUtil may be helpful in implementing a custom clone method. Note: The contract of this method is that you must use super.clone() as the basis for your implementation.

Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractCategorizer<InputType,CategoryType>
Returns:
A clone of this object.

evaluateWithDiscriminant

public DefaultWeightedValueDiscriminant<CategoryType> evaluateWithDiscriminant(InputType input)
Description copied from interface: DiscriminantCategorizer
Evaluate the categorizer on the given input to produce the expected category plus a discriminant for later producing an ordering of how well items fit into that category.

Parameters:
input - The input value to categorize with a discriminate
Returns:
A pair containing the value and the discriminant value used for ordering results belonging to the same category.

getCategoryPairsToEvaluatorMap

public Map<Pair<CategoryType,CategoryType>,Evaluator<? super InputType,Boolean>> getCategoryPairsToEvaluatorMap()
Gets the mapping of false-true category pairs to the binary categorizer that distinguishes them.

Returns:
The mapping of category pairs to their binary categorizer.

setCategoryPairsToEvaluatorMap

public void setCategoryPairsToEvaluatorMap(Map<Pair<CategoryType,CategoryType>,Evaluator<? super InputType,Boolean>> categoryPairsToEvaluatorMap)
Sets the mapping of false-true category pairs to the binary categorizer that distinguishes them.

Parameters:
categoryPairsToEvaluatorMap - The mapping of category pairs to their binary categorizer.