gov.sandia.cognition.learning.algorithm
Class SequencePredictionLearner<DataType,LearnedType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.learning.algorithm.AbstractBatchLearnerContainer<BatchLearner<? super Collection<? extends InputOutputPair<? extends DataType,DataType>>,? extends LearnedType>>
          extended by gov.sandia.cognition.learning.algorithm.SequencePredictionLearner<DataType,LearnedType>
Type Parameters:
DataType - The data type to do sequence prediction learning over.
LearnedType - The type of object produced by this learner.
All Implemented Interfaces:
BatchLearner<Collection<? extends DataType>,LearnedType>, BatchLearnerContainer<BatchLearner<? super Collection<? extends InputOutputPair<? extends DataType,DataType>>,? extends LearnedType>>, CloneableSerializable, Serializable, Cloneable

public class SequencePredictionLearner<DataType,LearnedType>
extends AbstractBatchLearnerContainer<BatchLearner<? super Collection<? extends InputOutputPair<? extends DataType,DataType>>,? extends LearnedType>>
implements BatchLearner<Collection<? extends DataType>,LearnedType>

A wrapper learner that converts an unlabeled sequence of data into a sequence of prediction data using a fixed prediction horizon. If the input data contains several sequences then it should be represented as a multi-collection.

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

Field Summary
static int DEFAULT_PREDICTION_HORIZION
          The default prediction horizon is 1.
protected  int predictionHorizon
          The prediction horizon, which is the number of samples in the future to try to learn to predict.
 
Fields inherited from class gov.sandia.cognition.learning.algorithm.AbstractBatchLearnerContainer
learner
 
Constructor Summary
SequencePredictionLearner()
          Creates a new SequencePredictionLearner with default parameters.
SequencePredictionLearner(BatchLearner<? super Collection<? extends InputOutputPair<? extends DataType,DataType>>,? extends LearnedType> learner, int predictionHorizon)
          Creates a new SequencePredictionLearner with the given learner and prediction horizon.
 
Method Summary
static
<DataType> MultiCollection<InputOutputPair<DataType,DataType>>
createPredictionDataset(Collection<? extends DataType> data, int predictionHorizon)
          Takes a collection and creates a multi-collection of sequences of input-output pairs that are from the given sequence with the given prediction horizon.
static
<DataType> MultiCollection<InputOutputPair<DataType,DataType>>
createPredictionDataset(MultiCollection<? extends DataType> data, int predictionHorizon)
          Takes a multi-collection and creates a multi-collection of sequences of input-output pairs that are from the given sequence with the given prediction horizon.
 int getPredictionHorizion()
          Gets the prediction horizon, which is the number of samples ahead in time that the learner is to predict.
 LearnedType learn(Collection<? extends DataType> data)
          The learn method creates an object of ResultType using data of type DataType, using some form of "learning" algorithm.
 LearnedType learn(MultiCollection<? extends DataType> data)
          Converts the given multi-collection of data sequences to create sequences of input-output pairs to learn over.
 void setPredictionHorizon(int predictionHorizon)
          Sets the prediction horizon, which is the number of samples ahead in time that the learner is to predict.
 
Methods inherited from class gov.sandia.cognition.learning.algorithm.AbstractBatchLearnerContainer
clone, getLearner, setLearner
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.util.CloneableSerializable
clone
 

Field Detail

DEFAULT_PREDICTION_HORIZION

public static final int DEFAULT_PREDICTION_HORIZION
The default prediction horizon is 1.

See Also:
Constant Field Values

predictionHorizon

protected int predictionHorizon
The prediction horizon, which is the number of samples in the future to try to learn to predict. It must be a positive number.

Constructor Detail

SequencePredictionLearner

public SequencePredictionLearner()
Creates a new SequencePredictionLearner with default parameters.


SequencePredictionLearner

public SequencePredictionLearner(BatchLearner<? super Collection<? extends InputOutputPair<? extends DataType,DataType>>,? extends LearnedType> learner,
                                 int predictionHorizon)
Creates a new SequencePredictionLearner with the given learner and prediction horizon.

Parameters:
learner - The supervised learner to call on the prediction sequence.
predictionHorizon - The prediction horizon, which is the number of samples in the future to try to learn to predict. It must be a positive number.
Method Detail

learn

public LearnedType learn(Collection<? extends DataType> data)
Description copied from interface: BatchLearner
The learn method creates an object of ResultType using data of type DataType, using some form of "learning" algorithm.

Specified by:
learn in interface BatchLearner<Collection<? extends DataType>,LearnedType>
Parameters:
data - The data that the learning algorithm will use to create an object of ResultType.
Returns:
The object that is created based on the given data using the learning algorithm.

learn

public LearnedType learn(MultiCollection<? extends DataType> data)
Converts the given multi-collection of data sequences to create sequences of input-output pairs to learn over.

Parameters:
data - The data to learn a prediction over.
Returns:
The object learned over the input-output prediction pairs.

createPredictionDataset

public static <DataType> MultiCollection<InputOutputPair<DataType,DataType>> createPredictionDataset(Collection<? extends DataType> data,
                                                                                                     int predictionHorizon)
Takes a collection and creates a multi-collection of sequences of input-output pairs that are from the given sequence with the given prediction horizon.

Type Parameters:
DataType - The data type to create a prediction dataset for.
Parameters:
data - A collection (or multi-collection) to convert into a prediction collection.
predictionHorizon - The prediction horizon to create the prediction dataset over. Must be positive.
Returns:
A multi-collection containing the input-output pairs that correspond to the prediction problem of prediction the output that is predictionHorizon elements after the input.

createPredictionDataset

public static <DataType> MultiCollection<InputOutputPair<DataType,DataType>> createPredictionDataset(MultiCollection<? extends DataType> data,
                                                                                                     int predictionHorizon)
Takes a multi-collection and creates a multi-collection of sequences of input-output pairs that are from the given sequence with the given prediction horizon. It treats each collection in the given multi-collection as a separate sequence, so it does not create data points that cross the the boundary between them.

Type Parameters:
DataType - The data type to create a prediction dataset for.
Parameters:
data - A collection (or multi-collection) to convert into a prediction collection.
predictionHorizon - The prediction horizon to create the prediction dataset over. Must be positive.
Returns:
A multi-collection containing the input-output pairs that correspond to the prediction problem of prediction the output that is predictionHorizon elements after the input.

getPredictionHorizion

public int getPredictionHorizion()
Gets the prediction horizon, which is the number of samples ahead in time that the learner is to predict.

Returns:
The prediction horizon.

setPredictionHorizon

public void setPredictionHorizon(int predictionHorizon)
Sets the prediction horizon, which is the number of samples ahead in time that the learner is to predict.

Parameters:
predictionHorizon - The prediction horizon. Must be positive.