Package org.tribuo.evaluation
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
A k-fold splitter to be used in cross-validation.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
KFoldSplitter.TrainTestFold<T extends Output<T>>
Stores a train/test split for a dataset. -
Field Summary
Modifier and TypeFieldDescriptionprotected final int
protected final SplittableRandom
protected final long
-
Constructor Summary
ConstructorDescriptionKFoldSplitter
(int nsplits) Builds a k-fold splitter usingTrainer.DEFAULT_SEED
as 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_SEED
as 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 % nsplits
folds have sizensamples/nsplits + 1
and 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
-