gov.sandia.cognition.learning.function.distance
Class DivergencesEvaluator<InputType,ValueType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.math.matrix.DefaultVectorFactoryContainer
          extended by gov.sandia.cognition.learning.function.distance.DivergencesEvaluator<InputType,ValueType>
Type Parameters:
InputType - The type of input value that the class evaluates. It is the second parameter passed to the divergence function. Typically a type like a Vector.
ValueType - The type of value that the divergence is computed from. It is the first parameter passed to the divergence function. It is typically a type like Vector or CenteroidCluster.
All Implemented Interfaces:
Evaluator<InputType,Vector>, DivergenceFunctionContainer<ValueType,InputType>, VectorFactoryContainer, VectorOutputEvaluator<InputType,Vector>, CloneableSerializable, Serializable, Cloneable

public class DivergencesEvaluator<InputType,ValueType>
extends DefaultVectorFactoryContainer
implements VectorOutputEvaluator<InputType,Vector>, DivergenceFunctionContainer<ValueType,InputType>

Evaluates the divergence (distance) between an input and a list of values, storing the resulting divergence values in a vector. This can be used as a feature representation built from something like a clustering algorithm or from a set of prototype/basis elements.

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

Nested Class Summary
static class DivergencesEvaluator.Learner<DataType,InputType,ValueType>
          A learner adapter for the DivergencesEvaluator.
 
Field Summary
protected  DivergenceFunction<? super ValueType,? super InputType> divergenceFunction
          The divergence function to apply between the data and the input.
protected  Collection<ValueType> values
          The data to evaluate the divergence from.
 
Fields inherited from class gov.sandia.cognition.math.matrix.DefaultVectorFactoryContainer
vectorFactory
 
Constructor Summary
DivergencesEvaluator()
          Creates a new DivergencesEvaluator with a null divergence function and an empty set of values.
DivergencesEvaluator(DivergenceFunction<? super ValueType,? super InputType> divergenceFunction, Collection<ValueType> values)
          Creates a new DivergencesEvaluator with the given divergence and values.
DivergencesEvaluator(DivergenceFunction<? super ValueType,? super InputType> divergenceFunction, Collection<ValueType> values, VectorFactory<?> vectorFactory)
          Creates a new DivergencesEvaluator with the given divergence and values.
 
Method Summary
 DivergencesEvaluator<InputType,ValueType> clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
static
<InputType,ValueType>
DivergencesEvaluator<InputType,ValueType>
create(DivergenceFunction<? super ValueType,? super InputType> divergenceFunction, Collection<ValueType> values)
          Convinience method for creation a DivergeceEvaluator.
 Vector evaluate(InputType input)
          Evaluates the function on the given input and returns the output.
 DivergenceFunction<? super ValueType,? super InputType> getDivergenceFunction()
          Gets the divergence function used by this object.
 int getOutputDimensionality()
          Gets the expected dimensionality of the output vector of the evaluator, if it is known.
 Collection<ValueType> getValues()
          Gets the values that the divergence is computed from using the divergence function to the input.
 void setDivergenceFunction(DivergenceFunction<? super ValueType,? super InputType> divergenceFunction)
          Sets the divergence function to use from the values to the inputs.
 void setValues(Collection<ValueType> values)
          Sets the values that the divergence is computed from using the divergence function to the input.
 
Methods inherited from class gov.sandia.cognition.math.matrix.DefaultVectorFactoryContainer
getVectorFactory, setVectorFactory
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

divergenceFunction

protected DivergenceFunction<? super ValueType,? super InputType> divergenceFunction
The divergence function to apply between the data and the input.


values

protected Collection<ValueType> values
The data to evaluate the divergence from.

Constructor Detail

DivergencesEvaluator

public DivergencesEvaluator()
Creates a new DivergencesEvaluator with a null divergence function and an empty set of values.


DivergencesEvaluator

public DivergencesEvaluator(DivergenceFunction<? super ValueType,? super InputType> divergenceFunction,
                            Collection<ValueType> values)
Creates a new DivergencesEvaluator with the given divergence and values.

Parameters:
divergenceFunction - The divergence function to use.
values - The values to calculate the divergence from.

DivergencesEvaluator

public DivergencesEvaluator(DivergenceFunction<? super ValueType,? super InputType> divergenceFunction,
                            Collection<ValueType> values,
                            VectorFactory<?> vectorFactory)
Creates a new DivergencesEvaluator with the given divergence and values.

Parameters:
divergenceFunction - The divergence function to use.
values - The values to calculate the divergence from.
vectorFactory - The vector factory to use.
Method Detail

clone

public DivergencesEvaluator<InputType,ValueType> 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 Vector 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,Vector>
Parameters:
input - The input to evaluate.
Returns:
The output produced by evaluating the input.

getOutputDimensionality

public int getOutputDimensionality()
Description copied from interface: VectorOutputEvaluator
Gets the expected dimensionality of the output vector of the evaluator, if it is known. If it is not known, -1 is returned.

Specified by:
getOutputDimensionality in interface VectorOutputEvaluator<InputType,Vector>
Returns:
The expected dimensionality of the output vector of the evaluator, or -1 if it is not known.

getDivergenceFunction

public DivergenceFunction<? super ValueType,? super InputType> getDivergenceFunction()
Description copied from interface: DivergenceFunctionContainer
Gets the divergence function used by this object.

Specified by:
getDivergenceFunction in interface DivergenceFunctionContainer<ValueType,InputType>
Returns:
The divergence function.

setDivergenceFunction

public void setDivergenceFunction(DivergenceFunction<? super ValueType,? super InputType> divergenceFunction)
Sets the divergence function to use from the values to the inputs.

Parameters:
divergenceFunction - The divergence function to use.

getValues

public Collection<ValueType> getValues()
Gets the values that the divergence is computed from using the divergence function to the input.

Returns:
The values that the distance is computed from.

setValues

public void setValues(Collection<ValueType> values)
Sets the values that the divergence is computed from using the divergence function to the input.

Parameters:
values - The values that the distance is computed from.

create

public static <InputType,ValueType> DivergencesEvaluator<InputType,ValueType> create(DivergenceFunction<? super ValueType,? super InputType> divergenceFunction,
                                                                                     Collection<ValueType> values)
Convinience method for creation a DivergeceEvaluator.

Type Parameters:
InputType - The type of input value that the class evaluates.
ValueType - The type of value that the divergence is computed from.
Parameters:
divergenceFunction - The divergence function to use.
values - The values to calculate the divergence from.
Returns:
A new evaluator.