public class KFoldIterator extends Object implements DataSetIterator
Modifier and Type | Field and Description |
---|---|
protected DataSet |
allData |
protected int[] |
intervalBoundaries |
protected int |
k |
protected int |
kCursor |
protected int |
N |
protected DataSetPreProcessor |
preProcessor |
protected DataSet |
test |
protected DataSet |
train |
Constructor and Description |
---|
KFoldIterator(DataSet allData)
Create a k-fold cross-validation iterator given the dataset and k=10 train-test splits.
|
KFoldIterator(int k,
DataSet allData)
Create an iterator given the dataset with given k train-test splits
N number of samples are split into k batches.
|
Modifier and Type | Method and Description |
---|---|
boolean |
asyncSupported()
Does this DataSetIterator support asynchronous prefetching of multiple DataSet objects?
Most DataSetIterators do, but in some cases it may not make sense to wrap this iterator in an
iterator that does asynchronous prefetching.
|
int |
batch()
The number of examples in every fold is (N / k),
except when (N % k) > 0, when the first (N % k) folds contain (N / k) + 1 examples
|
List<String> |
getLabels()
Get dataset iterator class labels, if any.
|
DataSetPreProcessor |
getPreProcessor()
Returns preprocessors, if defined
|
boolean |
hasNext() |
int |
inputColumns()
Input columns for the dataset
|
DataSet |
next() |
DataSet |
next(int num)
Like the standard next method but allows a
customizable number of examples returned
|
protected void |
nextFold() |
void |
remove() |
void |
reset()
Shuffles the dataset and resets to the first fold
|
boolean |
resetSupported()
Is resetting supported by this DataSetIterator? Many DataSetIterators do support resetting,
but some don't
|
void |
setPreProcessor(DataSetPreProcessor preProcessor)
Set a pre processor
|
DataSet |
testFold() |
int |
totalExamples()
Returns total number of examples in the dataset (all k folds)
|
int |
totalOutcomes()
The number of labels for the dataset
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
protected DataSet allData
protected int k
protected int N
protected int[] intervalBoundaries
protected int kCursor
protected DataSet test
protected DataSet train
protected DataSetPreProcessor preProcessor
public KFoldIterator(DataSet allData)
allData
- DataSet to split into k foldspublic KFoldIterator(int k, DataSet allData)
k
- number of folds (optional, defaults to 10)allData
- DataSet to split into k foldspublic DataSet next(int num) throws UnsupportedOperationException
DataSetIterator
next
in interface DataSetIterator
num
- the number of examplesUnsupportedOperationException
public int totalExamples()
public int inputColumns()
DataSetIterator
inputColumns
in interface DataSetIterator
public int totalOutcomes()
DataSetIterator
totalOutcomes
in interface DataSetIterator
public boolean resetSupported()
DataSetIterator
resetSupported
in interface DataSetIterator
public boolean asyncSupported()
DataSetIterator
asyncSupported
in interface DataSetIterator
public void reset()
reset
in interface DataSetIterator
public int batch()
batch
in interface DataSetIterator
public void setPreProcessor(DataSetPreProcessor preProcessor)
DataSetIterator
setPreProcessor
in interface DataSetIterator
preProcessor
- a pre processor to setpublic DataSetPreProcessor getPreProcessor()
DataSetIterator
getPreProcessor
in interface DataSetIterator
public List<String> getLabels()
DataSetIterator
getLabels
in interface DataSetIterator
protected void nextFold()
public DataSet testFold()
Copyright © 2019. All rights reserved.