gov.sandia.cognition.learning.experiment
Class RandomFoldCreator<DataType>

java.lang.Object
  extended by gov.sandia.cognition.learning.experiment.RandomFoldCreator<DataType>
Type Parameters:
DataType - The type of data to create the folds for.
All Implemented Interfaces:
ValidationFoldCreator<DataType,DataType>, Serializable

public class RandomFoldCreator<DataType>
extends Object
implements ValidationFoldCreator<DataType,DataType>

The RandomFoldCreator class makes use of a randomized data partitioner to create a set number of folds for a set of data by passing the data to the data partitioner multiple times.

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

Field Summary
static int DEFAULT_NUM_FOLDS
          The default number of folds is 10.
protected  int numFolds
          The number of folds to create.
protected  RandomizedDataPartitioner<DataType> partitioner
          The partitioner used for each fold.
 
Constructor Summary
RandomFoldCreator()
          Creates a new instance of RandomFoldCreator.
RandomFoldCreator(int numFolds, RandomizedDataPartitioner<DataType> partitioner)
          Creates a new instance of RandomFoldCreator.
 
Method Summary
 ArrayList<PartitionedDataset<DataType>> createFolds(Collection<? extends DataType> data)
          Creates the folds from the given data by passing the data into the set data partitioner multiple times.
 int getNumFolds()
          Gets the number of folds to create.
 RandomizedDataPartitioner<DataType> getPartitioner()
          Gets the randomized partitioner to use.
 void setNumFolds(int numFolds)
          Sets the number of folds to create.
 void setPartitioner(RandomizedDataPartitioner<DataType> partitioner)
          Sets the randomized partitioner to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_NUM_FOLDS

public static final int DEFAULT_NUM_FOLDS
The default number of folds is 10.

See Also:
Constant Field Values

numFolds

protected int numFolds
The number of folds to create.


partitioner

protected RandomizedDataPartitioner<DataType> partitioner
The partitioner used for each fold.

Constructor Detail

RandomFoldCreator

public RandomFoldCreator()
Creates a new instance of RandomFoldCreator.


RandomFoldCreator

public RandomFoldCreator(int numFolds,
                         RandomizedDataPartitioner<DataType> partitioner)
Creates a new instance of RandomFoldCreator.

Parameters:
numFolds - The number of folds to create.
partitioner - The partitioner to use to create the folds.
Method Detail

createFolds

public ArrayList<PartitionedDataset<DataType>> createFolds(Collection<? extends DataType> data)
Creates the folds from the given data by passing the data into the set data partitioner multiple times.

Specified by:
createFolds in interface ValidationFoldCreator<DataType,DataType>
Parameters:
data - The data to partition into multiple folds.
Returns:
The folds of partitioned data.

getNumFolds

public int getNumFolds()
Gets the number of folds to create.

Returns:
The number of folds to create.

setNumFolds

public void setNumFolds(int numFolds)
Sets the number of folds to create. Must be greater than zero.

Parameters:
numFolds - The number of folds to create.

getPartitioner

public RandomizedDataPartitioner<DataType> getPartitioner()
Gets the randomized partitioner to use.

Returns:
The randomized partitioner.

setPartitioner

public void setPartitioner(RandomizedDataPartitioner<DataType> partitioner)
Sets the randomized partitioner to use.

Parameters:
partitioner - The randomized partitioner.