gov.sandia.cognition.learning.data
Class DefaultInputOutputPair<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>
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>, CloneableSerializable, Pair<InputType,OutputType>, Serializable, Cloneable
Direct Known Subclasses:
AdaptiveRejectionSampling.Point, DefaultWeightedInputOutputPair, InputOutputSlopeTriplet

public class DefaultInputOutputPair<InputType,OutputType>
extends AbstractInputOutputPair<InputType,OutputType>

A default implementation of the InputOutputPair interface. It stores a pointer to the input and output objects that make up the pair.

Since:
3.0
Author:
Justin Basilico, Kevin R. Dixon
See Also:
Serialized Form

Constructor Summary
DefaultInputOutputPair()
          Creates a new DefaultInputOutputPair with both the input and output as null.
DefaultInputOutputPair(InputType input, OutputType output)
          Creates a new DefaultInputOutputPair with the given input and output.
DefaultInputOutputPair(Pair<? extends InputType,? extends OutputType> pair)
          Creates a new DefaultInputOutputPair using the first element of the given pair as the input and the second element of the given pair as the output.
 
Method Summary
static
<InputType,OutputType>
DefaultInputOutputPair<InputType,OutputType>
create()
          Convenience method to create a new DefaultInputOutputPair.
static
<InputType,OutputType>
DefaultInputOutputPair<InputType,OutputType>
create(InputType input, OutputType output)
          Convenience method to create a new DefaultInputOutputPair.
 InputType getInput()
          Gets the input.
 OutputType getOutput()
          Gets the output.
static
<InputType,OutputType>
ArrayList<DefaultInputOutputPair<InputType,OutputType>>
labelCollection(Collection<InputType> inputs, OutputType output)
          Takes a collection of input values and a single output value and creates a new collection of default input output pairs with each of the given inputs and the given output.
static
<InputType,OutputType>
ArrayList<DefaultInputOutputPair<InputType,OutputType>>
mergeCollections(Collection<InputType> inputs, Collection<OutputType> outputs)
          Takes two collections of data of equal size and creates a single ArrayList of InputOutputPairs out of them.
 void setInput(InputType input)
          Sets the input.
 void setOutput(OutputType output)
          Sets the output.
 
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
 

Constructor Detail

DefaultInputOutputPair

public DefaultInputOutputPair()
Creates a new DefaultInputOutputPair with both the input and output as null.


DefaultInputOutputPair

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

Parameters:
input - The input to store.
output - The output to store.

DefaultInputOutputPair

public DefaultInputOutputPair(Pair<? extends InputType,? extends OutputType> pair)
Creates a new DefaultInputOutputPair using the first element of the given pair as the input and the second element of the given pair as the output.

Parameters:
pair - The pair to get the input and output from.
Method Detail

getInput

public InputType getInput()
Description copied from interface: InputOutputPair
Gets the input.

Returns:
The input.

setInput

public void setInput(InputType input)
Sets the input.

Parameters:
input - The new input.

getOutput

public OutputType getOutput()
Description copied from interface: InputOutputPair
Gets the output.

Returns:
The output.

setOutput

public void setOutput(OutputType output)
Sets the output.

Parameters:
output - The new output.

create

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

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 default input-output pair.

create

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

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.
Returns:
A new default input-output pair with the given input and output.

mergeCollections

public static <InputType,OutputType> ArrayList<DefaultInputOutputPair<InputType,OutputType>> mergeCollections(Collection<InputType> inputs,
                                                                                                              Collection<OutputType> outputs)
Takes two collections of data of equal size and creates a single ArrayList of InputOutputPairs out of them.

Type Parameters:
InputType - The type of the input.
OutputType - The type of the output.
Parameters:
inputs - A collection of the data to transform into the input element of the pair. Must have the same number of elements as outputs.
outputs - A collection of data to transform into the output element of the pair. Must have the same number of elements as inputs.
Returns:
A new ArrayList<InputOutputPair> of the same size as the two given collections where the input is from the first collection and output is from the second.

labelCollection

public static <InputType,OutputType> ArrayList<DefaultInputOutputPair<InputType,OutputType>> labelCollection(Collection<InputType> inputs,
                                                                                                             OutputType output)
Takes a collection of input values and a single output value and creates a new collection of default input output pairs with each of the given inputs and the given output.

Type Parameters:
InputType - The type of the input.
OutputType - The type of the output.
Parameters:
inputs - A collection of the data to transform into the input element of the pair.
output - The value to use as the output element of the pair. (The label)
Returns:
A new ArrayList<InputOutputPair> of the same size as the input collection where the inputs are from the given collection and outputs are all the given value.