Class KFoldSplitter<T extends Output<T>>
java.lang.Object
org.tribuo.evaluation.KFoldSplitter<T>
- Type Parameters:
T- the type of the examples that make up the dataset to be split
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classKFoldSplitter.TrainTestFold<T extends Output<T>>Stores a train/test split for a dataset. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final intprotected final SplittableRandomprotected final long -
Constructor Summary
ConstructorsConstructorDescriptionKFoldSplitter(int nsplits) Builds a k-fold splitter usingTrainer.DEFAULT_SEEDas the seed.KFoldSplitter(int nsplits, long randomSeed) Builds a k-fold splitter. -
Method Summary
-
Field Details
-
nsplits
protected final int nsplits -
seed
protected final long seed -
rng
-
-
Constructor Details
-
KFoldSplitter
public KFoldSplitter(int nsplits, long randomSeed) Builds a k-fold splitter.- Parameters:
nsplits- The number of folds.randomSeed- The RNG seed.
-
KFoldSplitter
public KFoldSplitter(int nsplits) Builds a k-fold splitter usingTrainer.DEFAULT_SEEDas the seed.- Parameters:
nsplits- The number of folds.
-
-
Method Details
-
split
Splits a dataset into k consecutive folds; for each fold, the remaining k-1 folds form the training set.Note: the first
nsamples % nsplitsfolds have sizensamples/nsplits + 1and the remaining have sizensamples/nsplits, wherensamples = dataset.size().- Parameters:
dataset- The full datasetshuffle- Whether or not shuffle the dataset before generating folds- Returns:
- An iterator over TrainTestFolds
-