Modifier and Type | Class and Description |
---|---|
static class |
KFoldSplitter.TrainTestFold<T extends Output<T>>
Stores a train/test split for a dataset.
|
Modifier and Type | Field and Description |
---|---|
protected int |
nsplits |
protected SplittableRandom |
rng |
protected long |
seed |
Constructor and Description |
---|
KFoldSplitter(int nsplits)
Builds a k-fold splitter using
Trainer.DEFAULT_SEED as the seed. |
KFoldSplitter(int nsplits,
long randomSeed)
Builds a k-fold splitter.
|
Modifier and Type | Method and Description |
---|---|
Iterator<KFoldSplitter.TrainTestFold<T>> |
split(Dataset<T> dataset,
boolean shuffle)
Splits a dataset into k consecutive folds; for each fold, the remaining k-1 folds form the training set.
|
protected final int nsplits
protected final long seed
protected final SplittableRandom rng
public KFoldSplitter(int nsplits, long randomSeed)
nsplits
- The number of folds.randomSeed
- The RNG seed.public KFoldSplitter(int nsplits)
Trainer.DEFAULT_SEED
as the seed.nsplits
- The number of folds.public Iterator<KFoldSplitter.TrainTestFold<T>> split(Dataset<T> dataset, boolean shuffle)
Note: the first nsamples % nsplits
folds have size nsamples/nsplits + 1
and the remaining have
size nsamples/nsplits
, where nsamples = dataset.size()
.
dataset
- The full datasetshuffle
- Whether or not shuffle the dataset before generating foldsCopyright © 2015–2021 Oracle and/or its affiliates. All rights reserved.