DataType
- The type of data to partition.public class RandomDataPartitioner<DataType> extends AbstractRandomized implements RandomizedDataPartitioner<DataType>
RandomDataPartitioner
class implements a randomized data
partitioner that takes a collection of data and randomly splits it into
training and testing sets based on a fixed percentage of training data.Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_TRAINING_PERCENT
The default percentage of training data is 50%.
|
protected double |
trainingPercent
The percentage of training data.
|
random
Constructor and Description |
---|
RandomDataPartitioner()
Creates a new instance of RandomDataPartitioner.
|
RandomDataPartitioner(double trainingPercent,
java.util.Random random)
Creates a new instance of RandomDataPartitioner.
|
Modifier and Type | Method and Description |
---|---|
protected static void |
checkTrainingPercent(double trainingPercent)
Checks to make sure the training percent greater than 0.0 and less than
1.0.
|
PartitionedDataset<DataType> |
createPartition(java.util.Collection<? extends DataType> data)
Randomly partitions the given data into a training and testing set.
|
static <DataType> PartitionedDataset<DataType> |
createPartition(java.util.Collection<? extends DataType> data,
double trainingPercent,
java.util.Random random)
Randomly partitions the given data into a training and testing set.
|
double |
getTrainingPercent()
Gets the percentage of data to put in the training partition.
|
void |
setTrainingPercent(double trainingPercent)
Sets the percentage of data to put in the training partition.
|
clone, getRandom, setRandom
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getRandom, setRandom
public static final double DEFAULT_TRAINING_PERCENT
protected double trainingPercent
public RandomDataPartitioner()
public RandomDataPartitioner(double trainingPercent, java.util.Random random)
trainingPercent
- The percentage of training data.random
- The Random object to use.public PartitionedDataset<DataType> createPartition(java.util.Collection<? extends DataType> data)
createPartition
in interface DataPartitioner<DataType>
data
- The data to partition.public static <DataType> PartitionedDataset<DataType> createPartition(java.util.Collection<? extends DataType> data, double trainingPercent, java.util.Random random)
DataType
- The type of data to partition.data
- The data to partition.trainingPercent
- the percentage of data to put in the training
partition. Must be greater than 0.0 and less than 1.0.random
- The random number generator to use.public double getTrainingPercent()
public void setTrainingPercent(double trainingPercent)
trainingPercent
- The percentage of data to put in the training
partition.protected static final void checkTrainingPercent(double trainingPercent)
trainingPercent
- The percentage of data to put in the training
partition.