gov.sandia.cognition.learning.data
Class DefaultWeightedValueDiscriminant<ValueType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.util.AbstractWeighted
          extended by gov.sandia.cognition.util.DefaultWeightedValue<ValueType>
              extended by gov.sandia.cognition.learning.data.DefaultWeightedValueDiscriminant<ValueType>
Type Parameters:
ValueType - The type of value to discriminate between.
All Implemented Interfaces:
ValueDiscriminantPair<ValueType,Double>, CloneableSerializable, Pair<ValueType,Double>, Weighted, WeightedValue<ValueType>, Serializable, Cloneable

public class DefaultWeightedValueDiscriminant<ValueType>
extends DefaultWeightedValue<ValueType>
implements ValueDiscriminantPair<ValueType,Double>

An implementation of ValueDiscriminantPair that stores a double as the discriminant. It extends DefaultWeightedValue and thus also is a WeightedValue. This may be the most generally used implementation of the ValueDiscriminantPair since it covers the common case where the discriminant is a real value.

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

Nested Class Summary
 
Nested classes/interfaces inherited from class gov.sandia.cognition.util.DefaultWeightedValue
DefaultWeightedValue.WeightComparator
 
Field Summary
static double DEFAULT_WEIGHT
          The default weight is 0.0.
 
Fields inherited from class gov.sandia.cognition.util.DefaultWeightedValue
value
 
Fields inherited from class gov.sandia.cognition.util.AbstractWeighted
weight
 
Constructor Summary
DefaultWeightedValueDiscriminant()
          Creates a DefaultWeightedValueDiscriminant with a null value and a weight of 0.0.
DefaultWeightedValueDiscriminant(ValueType value, double weight)
          Creates a DefaultWeightedValueDiscriminant with the given value and weight.
DefaultWeightedValueDiscriminant(WeightedValue<? extends ValueType> other)
          Creates a new DefaultWeightedValueDiscriminant whose weight and value are taken from the given weighted value.
 
Method Summary
static
<ValueType>
DefaultWeightedValueDiscriminant<ValueType>
create(ValueType value, double weight)
          Convenience method for creating a new DefaultWeightedValueDiscriminant with the given value and weight.
static
<ValueType>
DefaultWeightedValueDiscriminant<ValueType>
create(WeightedValue<? extends ValueType> other)
          Convenience method for creating a new DefaultWeightedValueDiscriminant with a shallow copy of the given the given value and weight.
 Double getDiscriminant()
          Gets the discriminant for ordering instances of the same value.
 ValueType getFirst()
          Gets the first object.
 Double getSecond()
          Gets the second object.
 
Methods inherited from class gov.sandia.cognition.util.DefaultWeightedValue
clone, getValue, setValue
 
Methods inherited from class gov.sandia.cognition.util.AbstractWeighted
getWeight, setWeight
 
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.data.ValueDiscriminantPair
getValue
 
Methods inherited from interface gov.sandia.cognition.util.Weighted
getWeight
 

Field Detail

DEFAULT_WEIGHT

public static final double DEFAULT_WEIGHT
The default weight is 0.0.

See Also:
Constant Field Values
Constructor Detail

DefaultWeightedValueDiscriminant

public DefaultWeightedValueDiscriminant()
Creates a DefaultWeightedValueDiscriminant with a null value and a weight of 0.0.


DefaultWeightedValueDiscriminant

public DefaultWeightedValueDiscriminant(ValueType value,
                                        double weight)
Creates a DefaultWeightedValueDiscriminant with the given value and weight.

Parameters:
value - The value for the pair.
weight - The weight that is to be used as the discriminant.

DefaultWeightedValueDiscriminant

public DefaultWeightedValueDiscriminant(WeightedValue<? extends ValueType> other)
Creates a new DefaultWeightedValueDiscriminant whose weight and value are taken from the given weighted value.

Parameters:
other - The other weighted value to make a shallow copy of.
Method Detail

getDiscriminant

public Double getDiscriminant()
Description copied from interface: ValueDiscriminantPair
Gets the discriminant for ordering instances of the same value.

Specified by:
getDiscriminant in interface ValueDiscriminantPair<ValueType,Double>
Returns:
The discriminant in the pair.

getFirst

public ValueType getFirst()
Description copied from interface: Pair
Gets the first object.

Specified by:
getFirst in interface Pair<ValueType,Double>
Returns:
The first object.

getSecond

public Double getSecond()
Description copied from interface: Pair
Gets the second object.

Specified by:
getSecond in interface Pair<ValueType,Double>
Returns:
The second object.

create

public static <ValueType> DefaultWeightedValueDiscriminant<ValueType> create(ValueType value,
                                                                             double weight)
Convenience method for creating a new DefaultWeightedValueDiscriminant with the given value and weight.

Type Parameters:
ValueType - The type of value to discriminate between.
Parameters:
value - The value for the pair.
weight - The weight that is to be used as the discriminant.
Returns:
A new discriminant object.

create

public static <ValueType> DefaultWeightedValueDiscriminant<ValueType> create(WeightedValue<? extends ValueType> other)
Convenience method for creating a new DefaultWeightedValueDiscriminant with a shallow copy of the given the given value and weight.

Type Parameters:
ValueType - The type of value to discriminate between.
Parameters:
other - The other value to make a shallow copy of.
Returns:
A new discriminant object.