com.penguinwerks.jodene
Class ExampleSet

java.lang.Object
  extended bycom.penguinwerks.jodene.ExampleSet
All Implemented Interfaces:
java.io.Serializable

public class ExampleSet
extends java.lang.Object
implements java.io.Serializable

An example set is a set of examples. In addition to tracking the examples, the example set has the ability to create subsets of itself.

Author:
Paul Hoehne
See Also:
Serialized Form

Constructor Summary
ExampleSet()
           
 
Method Summary
 void addExample(Example example)
          Adds an example to this example set.
 ExampleSet[] divideLinear(double[] pctSizes)
          Same as dividLinear using integer sizes, except the sizes are expressed as percentages.
 ExampleSet[] divideLinear(int[] sizes)
          Divides the example set into sub sets based on the sizes in the size array.
 ExampleSet[] divideRandom(double[] pctSizes)
          Sames as divideRandom using integer sizes, except the sizes are expressed as percentages.
 ExampleSet[] divideRandom(int[] sizes)
          Divide this data set (without modifying it) into two data sets.
 Example get(int index)
          Returns the example at a given index.
 int getSize()
          Returns the size of the example set.
static ExampleSet makeExamples(java.util.List data, java.util.List inputs, java.util.List outputs)
          A static factory function that builds an example set from data, and the list of input and output names.
 Example nextExample()
          Returns the next example.
 ExampleSet shuffle()
          Shuffle the examples so they appear in random order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExampleSet

public ExampleSet()
Method Detail

addExample

public void addExample(Example example)
Adds an example to this example set.

Parameters:
example - A new example.

nextExample

public Example nextExample()
Returns the next example. This emulates a circular buffer, so it resets its iterator if necessary. It returns null if the example set is empty.

Returns:
An example.

get

public Example get(int index)
Returns the example at a given index. Returns null if the index is out of range.

Parameters:
index - The error at a given index.
Returns:
An example.

getSize

public int getSize()
Returns the size of the example set.

Returns:
The size of the example set.

makeExamples

public static ExampleSet makeExamples(java.util.List data,
                                      java.util.List inputs,
                                      java.util.List outputs)
A static factory function that builds an example set from data, and the list of input and output names. The input names and output names are subsets of the names in the name-values pairs in the data list. The list of data is the list as provided from the data-reader. It is ia list of name-value pairs.

Parameters:
data - The name-value pairs.
inputs - The list of input field names.
outputs - The list of output field names.
Returns:
The newly created example set.

divideRandom

public ExampleSet[] divideRandom(int[] sizes)
                          throws ExampleSetException
Divide this data set (without modifying it) into two data sets. The data elements will be chosen at random, and the number and sizes of the data sets are defined in the array sizes

Parameters:
sizes - The array of sizes for the sub-sets.
Returns:
an Array of example sets.
Throws:
ExampleSetException - Thrown if there is a problem with the sizes array.

divideRandom

public ExampleSet[] divideRandom(double[] pctSizes)
                          throws ExampleSetException
Sames as divideRandom using integer sizes, except the sizes are expressed as percentages.

Parameters:
pctSizes - The percentage of the example set to choose.
Returns:
An array of example sets.
Throws:
ExampleSetException - Thrown if there is a problem with the percent sizes.

divideLinear

public ExampleSet[] divideLinear(int[] sizes)
                          throws ExampleSetException
Divides the example set into sub sets based on the sizes in the size array. the data elements are selected by linearly cycling through the examples in the example set.

Parameters:
sizes - An array of the sizes of the example sets.
Returns:
An array of example sets.
Throws:
ExampleSetException - Thrown if there is a problem with the sizes.

divideLinear

public ExampleSet[] divideLinear(double[] pctSizes)
                          throws ExampleSetException
Same as dividLinear using integer sizes, except the sizes are expressed as percentages.

Parameters:
pctSizes - The sizes expressed as percentages.
Returns:
An array of subsets of the example set.
Throws:
ExampleSetException - Thrown if there is a problem with the sizes.

shuffle

public ExampleSet shuffle()
                   throws ExampleSetException
Shuffle the examples so they appear in random order. I generates a new Example Set, leaving the original unchanged.

Returns:
The shuffled example set
Throws:
ExampleSetException - Thrown if there is a problem with the example set.