org.encog.ml.data.temporal
Class TemporalMLDataSet

java.lang.Object
  extended by org.encog.ml.data.basic.BasicMLDataSet
      extended by org.encog.neural.data.basic.BasicNeuralDataSet
          extended by org.encog.ml.data.temporal.TemporalMLDataSet
All Implemented Interfaces:
Serializable, Iterable<MLDataPair>, MLDataSet, NeuralDataSet
Direct Known Subclasses:
MarketMLDataSet

public class TemporalMLDataSet
extends BasicNeuralDataSet
implements Serializable

This class implements a temporal neural data set. A temporal neural dataset is designed to use a neural network to predict. A temporal dataset is a stream of data over a time range. This time range is broken up into "points". Each point can contain one or more values. These values are either the values that you would like to predict, or use to predict. It is possible for a value to be both predicted and used to predict. For example, if you were trying to predict a trend in a stock's price fluctuations you might very well use the security price for both. Each point that we have data for is stored in the TemporalPoint class. Each TemporalPoint will contain one more data values. These data values are described by the TemporalDataDescription class. For example, if you had five TemporalDataDescription objects added to this class, each Temporal point object would contain five values. Points are arranged by sequence number. No two points can have the same sequence numbers. Methods are provided to allow you to add points using the Date class. These dates are resolved to sequence number using the level of granularity specified for this class. No two points can occupy the same granularity increment.

Author:
jheaton
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.encog.ml.data.basic.BasicMLDataSet
BasicMLDataSet.BasicMLIterator
 
Field Summary
static String ADD_NOT_SUPPORTED
          Error message: adds are not supported.
 
Constructor Summary
TemporalMLDataSet(int inputWindowSize, int predictWindowSize)
          Construct a dataset.
 
Method Summary
 void add(MLData data)
          Adding directly is not supported.
 void add(MLData inputData, MLData idealData)
          Adding directly is not supported.
 void add(MLDataPair inputData)
          Adding directly is not supported.
 void addDescription(TemporalDataDescription desc)
          Add a data description.
 int calculateActualSetSize()
          Calculate the actual set size, this is the number of training set entries that will be generated.
 void calculateNeuronCounts()
          Calculate how many input and output neurons will be needed for the current data.
 int calculatePointsInRange()
          Calculate how many points are in the high and low range.
 int calculateStartIndex()
          Calculate the index to start at.
 void clear()
          Clear the entire dataset.
 TemporalPoint createPoint(Date when)
          Create a temporal point from a time.
 TemporalPoint createPoint(int sequence)
          Create a temporal data point using a sequence number.
 void generate()
          Generate the training sets.
 BasicNeuralData generateInputNeuralData(int index)
          Generate input neural data for the specified index.
 BasicNeuralData generateOutputNeuralData(int index)
          Generate neural ideal data for the specified index.
 List<TemporalDataDescription> getDescriptions()
           
 int getDesiredSetSize()
           
 int getHighSequence()
           
 int getInputNeuronCount()
           
 int getInputWindowSize()
           
 int getLowSequence()
           
 int getOutputNeuronCount()
           
 List<TemporalPoint> getPoints()
           
 int getPredictWindowSize()
           
 int getSequenceFromDate(Date when)
          Create a sequence number from a time.
 TimeUnit getSequenceGrandularity()
           
 Date getStartingPoint()
           
 boolean isPointInRange(TemporalPoint point)
          Is the specified point within the range.
 void setDesiredSetSize(int desiredSetSize)
           
 void setHighSequence(int highSequence)
           
 void setInputWindowSize(int inputWindowSize)
           
 void setLowSequence(int lowSequence)
           
 void setPredictWindowSize(int predictWindowSize)
           
 void setSequenceGrandularity(TimeUnit sequenceGrandularity)
           
 void setStartingPoint(Date startingPoint)
           
 void sortPoints()
          Sort the points.
 
Methods inherited from class org.encog.ml.data.basic.BasicMLDataSet
clone, close, get, getData, getIdealSize, getInputSize, getRecord, getRecordCount, isSupervised, iterator, openAdditional, setData, size, toList
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.encog.ml.data.MLDataSet
close, get, getIdealSize, getInputSize, getRecord, getRecordCount, isSupervised, openAdditional, size
 
Methods inherited from interface java.lang.Iterable
iterator
 

Field Detail

ADD_NOT_SUPPORTED

public static final String ADD_NOT_SUPPORTED
Error message: adds are not supported.

See Also:
Constant Field Values
Constructor Detail

TemporalMLDataSet

public TemporalMLDataSet(int inputWindowSize,
                         int predictWindowSize)
Construct a dataset.

Parameters:
inputWindowSize - What is the input window size.
predictWindowSize - What is the prediction window size.
Method Detail

add

public void add(MLData data)
Adding directly is not supported. Rather, add temporal points and generate the training data.

Specified by:
add in interface MLDataSet
Overrides:
add in class BasicMLDataSet
Parameters:
data - Not used.

add

public void add(MLData inputData,
                MLData idealData)
Adding directly is not supported. Rather, add temporal points and generate the training data.

Specified by:
add in interface MLDataSet
Overrides:
add in class BasicMLDataSet
Parameters:
inputData - Not used.
idealData - Not used.

add

public void add(MLDataPair inputData)
Adding directly is not supported. Rather, add temporal points and generate the training data.

Specified by:
add in interface MLDataSet
Overrides:
add in class BasicMLDataSet
Parameters:
inputData - Not used.

addDescription

public void addDescription(TemporalDataDescription desc)
Add a data description.

Parameters:
desc - The data description to add.

calculateActualSetSize

public int calculateActualSetSize()
Calculate the actual set size, this is the number of training set entries that will be generated.

Returns:
The size of the training set.

calculateNeuronCounts

public void calculateNeuronCounts()
Calculate how many input and output neurons will be needed for the current data.


calculatePointsInRange

public int calculatePointsInRange()
Calculate how many points are in the high and low range. These are the points that the training set will be generated on.

Returns:
The number of points.

calculateStartIndex

public int calculateStartIndex()
Calculate the index to start at.

Returns:
the starting index.

clear

public void clear()
Clear the entire dataset.


createPoint

public TemporalPoint createPoint(Date when)
Create a temporal point from a time. Using the granularity each date is given a unique sequence number. No two dates that fall in the same granularity should be specified.

Parameters:
when - The time that this point should be created at.
Returns:
The point TemporalPoint created.

createPoint

public TemporalPoint createPoint(int sequence)
Create a temporal data point using a sequence number. They can also be created using time. No two points should have the same sequence number.

Parameters:
sequence - The sequence number.
Returns:
A new TemporalPoint object.

generate

public void generate()
Generate the training sets.


generateInputNeuralData

public BasicNeuralData generateInputNeuralData(int index)
Generate input neural data for the specified index.

Parameters:
index - The index to generate neural data for.
Returns:
The input neural data generated.

generateOutputNeuralData

public BasicNeuralData generateOutputNeuralData(int index)
Generate neural ideal data for the specified index.

Parameters:
index - The index to generate for.
Returns:
The neural data generated.

getDescriptions

public List<TemporalDataDescription> getDescriptions()
Returns:
A list of the data descriptions.

getDesiredSetSize

public int getDesiredSetSize()
Returns:
the desiredSetSize

getHighSequence

public int getHighSequence()
Returns:
the highSequence

getInputNeuronCount

public int getInputNeuronCount()
Returns:
the inputNeuronCount

getInputWindowSize

public int getInputWindowSize()
Returns:
the inputWindowSize

getLowSequence

public int getLowSequence()
Returns:
the lowSequence

getOutputNeuronCount

public int getOutputNeuronCount()
Returns:
the outputNeuronCount

getPoints

public List<TemporalPoint> getPoints()
Returns:
The temporal points.

getPredictWindowSize

public int getPredictWindowSize()
Returns:
the predictWindowSize

getSequenceFromDate

public int getSequenceFromDate(Date when)
Create a sequence number from a time. The first date will be zero, and subsequent dates will be increased according to the grandularity specified.

Parameters:
when - The date to generate the sequence number for.
Returns:
A sequence number.

getSequenceGrandularity

public TimeUnit getSequenceGrandularity()
Returns:
the sequenceGrandularity

getStartingPoint

public Date getStartingPoint()
Returns:
the startingPoint

isPointInRange

public boolean isPointInRange(TemporalPoint point)
Is the specified point within the range. If a point is in the selection range, then the point will be used to generate the training sets.

Parameters:
point - The point to consider.
Returns:
True if the point is within the range.

setDesiredSetSize

public void setDesiredSetSize(int desiredSetSize)
Parameters:
desiredSetSize - the desiredSetSize to set

setHighSequence

public void setHighSequence(int highSequence)
Parameters:
highSequence - the highSequence to set

setInputWindowSize

public void setInputWindowSize(int inputWindowSize)
Parameters:
inputWindowSize - the inputWindowSize to set

setLowSequence

public void setLowSequence(int lowSequence)
Parameters:
lowSequence - the lowSequence to set

setPredictWindowSize

public void setPredictWindowSize(int predictWindowSize)
Parameters:
predictWindowSize - the predictWindowSize to set

setSequenceGrandularity

public void setSequenceGrandularity(TimeUnit sequenceGrandularity)
Parameters:
sequenceGrandularity - the sequenceGrandularity to set

setStartingPoint

public void setStartingPoint(Date startingPoint)
Parameters:
startingPoint - the startingPoint to set

sortPoints

public void sortPoints()
Sort the points.



Copyright © 2014. All Rights Reserved.