gov.sandia.cognition.learning.function.categorization
Class WinnerTakeAllCategorizer<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.WinnerTakeAllCategorizer<InputType,CategoryType>
Type Parameters:
InputType - The type of the input the categorizer can use.
CategoryType - The type of category output by the categorizer.
All Implemented Interfaces:
Evaluator<InputType,CategoryType>, Categorizer<InputType,CategoryType>, DiscriminantCategorizer<InputType,CategoryType,Double>, CloneableSerializable, Serializable, Cloneable

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

Adapts an evaluator that outputs a vector to be used as a categorizer.

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

Nested Class Summary
static class WinnerTakeAllCategorizer.Learner<InputType,CategoryType>
          A learner for the adapter.
 
Field Summary
protected  Evaluator<? super InputType,? extends Vectorizable> evaluator
          The evaluator that outputs a vector to return.
 
Fields inherited from class gov.sandia.cognition.learning.function.categorization.AbstractCategorizer
categories
 
Constructor Summary
WinnerTakeAllCategorizer()
          Creates a new WinnerTakesAllCategorizer.
WinnerTakeAllCategorizer(Evaluator<? super InputType,? extends Vectorizable> evaluator, Set<CategoryType> categories)
          Creates a new WinnerTakesAllCategorizer.
 
Method Summary
 DefaultWeightedValueDiscriminant<CategoryType> evaluateWithDiscriminant(InputType input)
          Evaluates the categorizer and returns the category along with a weight.
 DefaultWeightedValueDiscriminant<CategoryType> findBestCategory(Vector output)
          Finds the best category (and its output value) from the given vector of outputs from a vector evaluator.
 Evaluator<? super InputType,? extends Vectorizable> getEvaluator()
          Gets the wrapped evaluator.
 void setCategories(Set<CategoryType> categories)
          Sets the Set of possible categories, which are the output values.
 void setEvaluator(Evaluator<? super InputType,? extends Vectorizable> evaluator)
          Sets the wrapped evaluator.
 
Methods inherited from class gov.sandia.cognition.learning.function.categorization.AbstractDiscriminantCategorizer
evaluate
 
Methods inherited from class gov.sandia.cognition.learning.function.categorization.AbstractCategorizer
clone, getCategories
 
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
 
Methods inherited from interface gov.sandia.cognition.util.CloneableSerializable
clone
 

Field Detail

evaluator

protected Evaluator<? super InputType,? extends Vectorizable> evaluator
The evaluator that outputs a vector to return.

Constructor Detail

WinnerTakeAllCategorizer

public WinnerTakeAllCategorizer()
Creates a new WinnerTakesAllCategorizer.


WinnerTakeAllCategorizer

public WinnerTakeAllCategorizer(Evaluator<? super InputType,? extends Vectorizable> evaluator,
                                Set<CategoryType> categories)
Creates a new WinnerTakesAllCategorizer.

Parameters:
evaluator - The evaluator that this class adapts.
categories - The set of categories.
Method Detail

evaluateWithDiscriminant

public DefaultWeightedValueDiscriminant<CategoryType> evaluateWithDiscriminant(InputType input)
Evaluates the categorizer and returns the category along with a weight.

Parameters:
input - The input to evaluate.
Returns:
The output plus its weight.

findBestCategory

public DefaultWeightedValueDiscriminant<CategoryType> findBestCategory(Vector output)
Finds the best category (and its output value) from the given vector of outputs from a vector evaluator. Ties are broken by taking the first category with the highest value.

Parameters:
output - The vector of outputs, one corresponding to each category.
Returns:
The category with the highest output value. Ties are broken by taking the first category with the highest value.

getEvaluator

public Evaluator<? super InputType,? extends Vectorizable> getEvaluator()
Gets the wrapped evaluator.

Returns:
The wrapped evaluator.

setEvaluator

public void setEvaluator(Evaluator<? super InputType,? extends Vectorizable> evaluator)
Sets the wrapped evaluator.

Parameters:
evaluator - The wrapped evaluator.

setCategories

public void setCategories(Set<CategoryType> categories)
Description copied from class: AbstractCategorizer
Sets the Set of possible categories, which are the output values.

Overrides:
setCategories in class AbstractCategorizer<InputType,CategoryType>
Parameters:
categories - The list of possible output categories.