gov.sandia.cognition.learning.data
Class DefaultWeightedInputOutputPair<InputType,OutputType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.learning.data.AbstractInputOutputPair<InputType,OutputType>
          extended by gov.sandia.cognition.learning.data.DefaultInputOutputPair<InputType,OutputType>
              extended by gov.sandia.cognition.learning.data.DefaultWeightedInputOutputPair<InputType,OutputType>
Type Parameters:
InputType - The type for the input object in the pair.
OutputType - The type for the output object in the pair.
All Implemented Interfaces:
InputOutputPair<InputType,OutputType>, WeightedInputOutputPair<InputType,OutputType>, CloneableSerializable, Pair<InputType,OutputType>, Weighted, WeightedPair<InputType,OutputType>, Serializable, Cloneable

public class DefaultWeightedInputOutputPair<InputType,OutputType>
extends DefaultInputOutputPair<InputType,OutputType>
implements WeightedInputOutputPair<InputType,OutputType>

A default implementation of the WeightedInputOutputPair interface. Stores pointers to the input and output plus the weight as a double.

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

Field Summary
static double DEFAULT_WEIGHT
          The default weight is 1.0.
 
Constructor Summary
DefaultWeightedInputOutputPair()
          Creates a new DefaultWeightedInputOutputPair with null as the input and output and a default weight of 1.0.
DefaultWeightedInputOutputPair(InputType input, OutputType output, double weight)
          Creates a new DefaultWeightedInputOutputPair with the given input, output, and weight.
DefaultWeightedInputOutputPair(Pair<? extends InputType,? extends OutputType> pair, double weight)
          Creates a new DefaultWeightedInputOutputPair with the given input and output from the given pair plus a weight.
DefaultWeightedInputOutputPair(WeightedInputOutputPair<? extends InputType,? extends OutputType> other)
          Creates a new DefaultWeightedInputOutputPair that is a shallow copy of the given WeightedInputOuptutPair.
 
Method Summary
static
<InputType,OutputType>
DefaultWeightedInputOutputPair<InputType,OutputType>
create()
          Convenience method to create a new, empty DefaultWeightedInputOutputPair.
static
<InputType,OutputType>
DefaultWeightedInputOutputPair<InputType,OutputType>
create(InputType input, OutputType output, double weight)
          Convenience method to create a new DefaultWeightedInputOutputPair.
 double getWeight()
          Gets the weight of the object.
static
<InputType,OutputType>
ArrayList<DefaultWeightedInputOutputPair<InputType,OutputType>>
mergeCollections(Collection<InputType> inputs, Collection<OutputType> outputs, Collection<? extends Number> weights)
          Takes two Collections of data and creates a single ArrayList out of them.
 void setWeight(double weight)
          Sets the weight for the pair.
 
Methods inherited from class gov.sandia.cognition.learning.data.DefaultInputOutputPair
create, getInput, getOutput, labelCollection, mergeCollections, setInput, setOutput
 
Methods inherited from class gov.sandia.cognition.learning.data.AbstractInputOutputPair
getFirst, getSecond, toString
 
Methods inherited from class gov.sandia.cognition.util.AbstractCloneableSerializable
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.learning.data.InputOutputPair
getInput, getOutput
 
Methods inherited from interface gov.sandia.cognition.util.Pair
getFirst, getSecond
 

Field Detail

DEFAULT_WEIGHT

public static final double DEFAULT_WEIGHT
The default weight is 1.0.

See Also:
Constant Field Values
Constructor Detail

DefaultWeightedInputOutputPair

public DefaultWeightedInputOutputPair()
Creates a new DefaultWeightedInputOutputPair with null as the input and output and a default weight of 1.0.


DefaultWeightedInputOutputPair

public DefaultWeightedInputOutputPair(InputType input,
                                      OutputType output,
                                      double weight)
Creates a new DefaultWeightedInputOutputPair with the given input, output, and weight.

Parameters:
input - The input.
output - The output.
weight - The weight.

DefaultWeightedInputOutputPair

public DefaultWeightedInputOutputPair(Pair<? extends InputType,? extends OutputType> pair,
                                      double weight)
Creates a new DefaultWeightedInputOutputPair with the given input and output from the given pair plus a weight.

Parameters:
pair - The pair to provide the input and output values.
weight - The weight.

DefaultWeightedInputOutputPair

public DefaultWeightedInputOutputPair(WeightedInputOutputPair<? extends InputType,? extends OutputType> other)
Creates a new DefaultWeightedInputOutputPair that is a shallow copy of the given WeightedInputOuptutPair.

Parameters:
other - The other weighted input-output pair to copy the values of.
Method Detail

getWeight

public double getWeight()
Description copied from interface: Weighted
Gets the weight of the object.

Specified by:
getWeight in interface Weighted
Returns:
The weight.

setWeight

public void setWeight(double weight)
Sets the weight for the pair.

Parameters:
weight - Weighting term for the InputOutputPair.

create

public static <InputType,OutputType> DefaultWeightedInputOutputPair<InputType,OutputType> create()
Convenience method to create a new, empty DefaultWeightedInputOutputPair.

Type Parameters:
InputType - The type for the input object in the pair.
OutputType - The type for the output object in the pair.
Returns:
A new, empty DefaultWeightedInputOutputPair.

create

public static <InputType,OutputType> DefaultWeightedInputOutputPair<InputType,OutputType> create(InputType input,
                                                                                                 OutputType output,
                                                                                                 double weight)
Convenience method to create a new DefaultWeightedInputOutputPair.

Type Parameters:
InputType - The type for the input object in the pair.
OutputType - The type for the output object in the pair.
Parameters:
input - The input.
output - The output.
weight - The weight.
Returns:
A new default weighted input-output pair with the given input, output, and weight.

mergeCollections

public static <InputType,OutputType> ArrayList<DefaultWeightedInputOutputPair<InputType,OutputType>> mergeCollections(Collection<InputType> inputs,
                                                                                                                      Collection<OutputType> outputs,
                                                                                                                      Collection<? extends Number> weights)
Takes two Collections of data and creates a single ArrayList out of them.

Type Parameters:
InputType - The type of the input.
OutputType - The type of the output.
Parameters:
inputs - Collection of the data to transform into the input of the WeightedInputOutputPair, must have the same size as targets
outputs - Collection of the data to transform into the output of the WeightedInputOutputPair, must have the same size as inputs
weights - Collection of weights, must have the same size as inputs/targets
Returns:
ArrayList of the same type as the input/output Collections