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.public class DivergencesEvaluator<InputType,ValueType> extends AbstractToVectorEncoder<InputType> implements VectorOutputEvaluator<InputType,Vector>, DivergenceFunctionContainer<ValueType,InputType>
Modifier and Type | Class and Description |
---|---|
static class |
DivergencesEvaluator.Learner<DataType,InputType,ValueType>
A learner adapter for the
DivergencesEvaluator . |
Modifier and Type | Field and Description |
---|---|
protected DivergenceFunction<? super ValueType,? super InputType> |
divergenceFunction
The divergence function to apply between the data and the input.
|
protected java.util.Collection<ValueType> |
values
The data to evaluate the divergence from.
|
vectorFactory
Constructor and Description |
---|
DivergencesEvaluator()
Creates a new
DivergencesEvaluator with a null divergence
function and an empty set of values. |
DivergencesEvaluator(DivergenceFunction<? super ValueType,? super InputType> divergenceFunction,
java.util.Collection<ValueType> values)
Creates a new
DivergencesEvaluator with the given divergence
and values. |
DivergencesEvaluator(DivergenceFunction<? super ValueType,? super InputType> divergenceFunction,
java.util.Collection<ValueType> values,
VectorFactory<?> vectorFactory)
Creates a new
DivergencesEvaluator with the given divergence
and values. |
Modifier and Type | Method and Description |
---|---|
DivergencesEvaluator<InputType,ValueType> |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
static <InputType,ValueType> |
create(DivergenceFunction<? super ValueType,? super InputType> divergenceFunction,
java.util.Collection<ValueType> values)
Convenience method for creation a
DivergeceEvaluator . |
void |
encode(InputType input,
Vector result,
int startIndex)
Encodes the given object into the given
Vector , starting at the
given index. |
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.
|
java.util.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(java.util.Collection<ValueType> values)
Sets the values that the divergence is computed from using the
divergence function to the input.
|
encode, evaluate, getVectorFactory, setVectorFactory
protected DivergenceFunction<? super ValueType,? super InputType> divergenceFunction
protected java.util.Collection<ValueType> values
public DivergencesEvaluator()
DivergencesEvaluator
with a null divergence
function and an empty set of values.public DivergencesEvaluator(DivergenceFunction<? super ValueType,? super InputType> divergenceFunction, java.util.Collection<ValueType> values)
DivergencesEvaluator
with the given divergence
and values.divergenceFunction
- The divergence function to use.values
- The values to calculate the divergence from.public DivergencesEvaluator(DivergenceFunction<? super ValueType,? super InputType> divergenceFunction, java.util.Collection<ValueType> values, VectorFactory<?> vectorFactory)
DivergencesEvaluator
with the given divergence
and values.divergenceFunction
- The divergence function to use.values
- The values to calculate the divergence from.vectorFactory
- The vector factory to use.public DivergencesEvaluator<InputType,ValueType> clone()
AbstractCloneableSerializable
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.clone
in interface CloneableSerializable
clone
in class AbstractCloneableSerializable
public void encode(InputType input, Vector result, int startIndex)
DataToVectorEncoder
Vector
, starting at the
given index.encode
in interface DataToVectorEncoder<InputType>
input
- The object to encode.result
- The vector to encode the object into.startIndex
- The index to start the encoding at.public int getOutputDimensionality()
VectorOutputEvaluator
getOutputDimensionality
in interface DataToVectorEncoder<InputType>
getOutputDimensionality
in interface VectorOutputEvaluator<InputType,Vector>
public DivergenceFunction<? super ValueType,? super InputType> getDivergenceFunction()
DivergenceFunctionContainer
getDivergenceFunction
in interface DivergenceFunctionContainer<ValueType,InputType>
public void setDivergenceFunction(DivergenceFunction<? super ValueType,? super InputType> divergenceFunction)
divergenceFunction
- The divergence function to use.public java.util.Collection<ValueType> getValues()
public void setValues(java.util.Collection<ValueType> values)
values
- The values that the distance is computed from.public static <InputType,ValueType> DivergencesEvaluator<InputType,ValueType> create(DivergenceFunction<? super ValueType,? super InputType> divergenceFunction, java.util.Collection<ValueType> values)
DivergeceEvaluator
.InputType
- The type of input value that the class evaluates.ValueType
- The type of value that the divergence is computed from.divergenceFunction
- The divergence function to use.values
- The values to calculate the divergence from.