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

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.learning.function.categorization.CompositeCategorizer<InputType,IntermediateType,CategoryType>
Type Parameters:
InputType - The type of input to the categorizer. It is the type of input to the preprocessor.
IntermediateType - The type of the intermediate values for the categorizer. It is the type of the output of the preprocessor and the input of the internal categorizer.
CategoryType - The type of the output of the categorizer. It is the type of the output of the internal categorizer as well.
All Implemented Interfaces:
Evaluator<InputType,CategoryType>, Categorizer<InputType,CategoryType>, CloneableSerializable, Serializable, Cloneable

public class CompositeCategorizer<InputType,IntermediateType,CategoryType>
extends AbstractCloneableSerializable
implements Categorizer<InputType,CategoryType>

Composes a preprocessor function with a categorizer. It takes an input value and passes it to the preprocessor to get an intermediate value then it passes the intermediate value to the categorizer to produce the output.

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

Field Summary
protected  Categorizer<? super IntermediateType,? extends CategoryType> categorizer
          The categorizer.
protected  Evaluator<? super InputType,? extends IntermediateType> preprocessor
          The preprocessor for the input data.
 
Constructor Summary
CompositeCategorizer()
          Creates a new CompositeCategorizer with the preprocessor and categorizer set to null.
CompositeCategorizer(Evaluator<? super InputType,? extends IntermediateType> preprocessor, Categorizer<? super IntermediateType,? extends CategoryType> categorizer)
          Creates a new CompositeCategorizer.
 
Method Summary
 CompositeCategorizer<InputType,IntermediateType,CategoryType> clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 CategoryType evaluate(InputType input)
          Evaluates the function on the given input and returns the output.
 Set<? extends CategoryType> getCategories()
          Gets the set of categories, which is just the set returned by the categorizer.
 Categorizer<? super IntermediateType,? extends CategoryType> getCategorizer()
          Gets the categorizer, which takes the output of the preprocessor and categorizes it.
 Evaluator<? super InputType,? extends IntermediateType> getPreprocessor()
          Gets the preprocessor, which takes the input and produces an intermediate value that is then passed to the categorizer.
 void setCategorizer(Categorizer<? super IntermediateType,? extends CategoryType> categorizer)
          Sets the categorizer, which takes the output of the preprocessor and categorizes it.
 void setPreprocessor(Evaluator<? super InputType,? extends IntermediateType> preprocessor)
          Sets the preprocessor, which takes the input and produces an intermediate value that is then passed to the categorizer.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

preprocessor

protected Evaluator<? super InputType,? extends IntermediateType> preprocessor
The preprocessor for the input data.


categorizer

protected Categorizer<? super IntermediateType,? extends CategoryType> categorizer
The categorizer.

Constructor Detail

CompositeCategorizer

public CompositeCategorizer()
Creates a new CompositeCategorizer with the preprocessor and categorizer set to null.


CompositeCategorizer

public CompositeCategorizer(Evaluator<? super InputType,? extends IntermediateType> preprocessor,
                            Categorizer<? super IntermediateType,? extends CategoryType> categorizer)
Creates a new CompositeCategorizer.

Parameters:
preprocessor - The preprocessing evaluator that is run on the input.
categorizer - The categorizer that takes the output of the preprocessor and categorizes it.
Method Detail

clone

public CompositeCategorizer<InputType,IntermediateType,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 AbstractCloneableSerializable
Returns:
A clone of this object.

evaluate

public CategoryType evaluate(InputType input)
Description copied from interface: Evaluator
Evaluates the function on the given input and returns the output.

Specified by:
evaluate in interface Evaluator<InputType,CategoryType>
Parameters:
input - The input to evaluate.
Returns:
The output produced by evaluating the input.

getCategories

public Set<? extends CategoryType> getCategories()
Gets the set of categories, which is just the set returned by the categorizer. If there is no categorizer, the set is null.

Specified by:
getCategories in interface Categorizer<InputType,CategoryType>
Returns:
The set of categories.

getPreprocessor

public Evaluator<? super InputType,? extends IntermediateType> getPreprocessor()
Gets the preprocessor, which takes the input and produces an intermediate value that is then passed to the categorizer.

Returns:
The preprocessor.

setPreprocessor

public void setPreprocessor(Evaluator<? super InputType,? extends IntermediateType> preprocessor)
Sets the preprocessor, which takes the input and produces an intermediate value that is then passed to the categorizer.

Parameters:
preprocessor - The preprocessor.

getCategorizer

public Categorizer<? super IntermediateType,? extends CategoryType> getCategorizer()
Gets the categorizer, which takes the output of the preprocessor and categorizes it.

Returns:
The categorizer.

setCategorizer

public void setCategorizer(Categorizer<? super IntermediateType,? extends CategoryType> categorizer)
Sets the categorizer, which takes the output of the preprocessor and categorizes it.

Parameters:
categorizer - The categorizer.